⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 在asp中怎樣用excel寫報表.htm

📁 较为详细的介绍了asp自定义的各种函数,方便asp的各种开发.
💻 HTM
📖 第 1 页 / 共 2 页
字号:
            &nbsp;<BR>str="provider=microsoft.jet.oledb.4.0;data &nbsp;source=" 
            &nbsp;&amp; &nbsp;Server.MapPath(".") &nbsp;&amp; &nbsp;"\data.mdb" 
            &nbsp;<BR>'Response.Write &nbsp;(str) &nbsp;<BR>DSC.ConnectionString 
            &nbsp;= &nbsp;"provider=microsoft.jet.oledb.4.0;data &nbsp;source=" 
            &nbsp;&amp; &nbsp;Server.MapPath(".") &nbsp;&amp; &nbsp;"\data.mdb" 
            &nbsp;<BR>&nbsp;<BR>DSC.RecordsetDefs.AddNew &nbsp;"SELECT 
            &nbsp;Month([OrderDate]) &nbsp;AS &nbsp;[Month], 
            &nbsp;Invoices.Salesperson, &nbsp;" &nbsp;&amp; &nbsp;_ 
            &nbsp;<BR>&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;"Sum(Invoices.ExtendedPrice) &nbsp;AS &nbsp;Sales 
            &nbsp;FROM &nbsp;Invoices &nbsp;" &nbsp;&amp; &nbsp;_ 
            &nbsp;<BR>&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;"WHERE 
            &nbsp;Invoices.OrderDate &nbsp;between &nbsp;#1/1/2002# &nbsp;and 
            &nbsp;#12/31/2002# &nbsp;" &nbsp;&amp; &nbsp;_ 
            &nbsp;<BR>&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;"GROUP &nbsp;BY 
            &nbsp;Month([OrderDate]), 
            &nbsp;Invoices.Salesperson",DSC.Constants.dscCommandText,"ChartData" 
            &nbsp;<BR>&nbsp;<BR>'BindChartToDSC &nbsp;m_m_cspace, &nbsp;DSC, 
            &nbsp;"ChartData", &nbsp;"month", &nbsp;"Sales" &nbsp;<BR>set 
            &nbsp;c &nbsp;= &nbsp;m_cspace.Constants 
            &nbsp;<BR>&nbsp;<BR>m_cspace.Clear &nbsp;<BR>&nbsp;<BR>' &nbsp;绑定数据源 
            &nbsp;<BR>set &nbsp;m_cspace.DataSource &nbsp;= &nbsp;dsc 
            &nbsp;<BR>&nbsp;<BR>m_cspace.DataMember &nbsp;= &nbsp;ChartData 
            &nbsp;<BR>&nbsp;<BR>set &nbsp;cht &nbsp;= 
            &nbsp;m_cspace.Charts.Add() &nbsp;<BR>cht.HasLegend &nbsp;= 
            &nbsp;True &nbsp;<BR>cht.Type &nbsp;= &nbsp;19 
            &nbsp;<BR>&nbsp;<BR>'增加一个图表标题,并格式化标题 &nbsp;<BR>cht.HasTitle &nbsp;= 
            &nbsp;True &nbsp;<BR>cht.Title.Caption &nbsp;= &nbsp; &nbsp; 
            &nbsp;m_sYear &nbsp;&amp; &nbsp;"的销售金额 &nbsp;" &nbsp;<BR>set 
            &nbsp;fnt &nbsp;= &nbsp;cht.Title.Font &nbsp;<BR>fnt.Name &nbsp;= 
            &nbsp;"宋体" &nbsp;<BR>fnt.Size &nbsp;= &nbsp;10 &nbsp;<BR>fnt.Bold 
            &nbsp;= &nbsp;True &nbsp;<BR>&nbsp;<BR>set &nbsp;ser &nbsp;= 
            &nbsp;cht.SeriesCollection.Add() &nbsp;<BR>ser.SetData 
            &nbsp;c.chDimCategories, &nbsp;0, &nbsp;"Salesperson" 
            &nbsp;<BR>ser.SetData &nbsp;c.chDimValues, &nbsp;0, &nbsp;"Sales" 
            &nbsp;<BR>&nbsp;<BR>set &nbsp;dls &nbsp;= 
            &nbsp;ser.DataLabelsCollection.Add() &nbsp;<BR>dls.HasPercentage 
            &nbsp;= &nbsp;True &nbsp;<BR>dls.HasValue &nbsp;= &nbsp;False 
            &nbsp;<BR>&nbsp;<BR>'m_sFilePath &nbsp;= 
            &nbsp;ExportChartToGIF(m_m_cspace) &nbsp;<BR>set &nbsp;m_fso &nbsp;= 
            &nbsp;CreateObject("Scripting.FileSystemObject") 
            &nbsp;<BR>sFullFileName &nbsp;= &nbsp;Server.MapPath(".") 
            &nbsp;&amp; &nbsp;"\" &nbsp;&amp; &nbsp;m_fso.GetTempName() 
            &nbsp;<BR>m_cspace.ExportPicture &nbsp;sFullFileName, &nbsp;"GIF", 
            &nbsp;800, &nbsp;400 &nbsp;<BR>&nbsp;<BR>'on &nbsp;error 
            &nbsp;resume &nbsp;next &nbsp;<BR>set &nbsp;m_objBinaryFile &nbsp;= 
            &nbsp;server.CreateObject("BinFileWrite.GetFileStream") 
            &nbsp;<BR>Response.BinaryWrite 
            &nbsp;m_objBinaryFile.GetFileBytes(CStr(sFullFileName)) 
            &nbsp;<BR>m_objBinaryFile.SendBinFile 
            &nbsp;CStr(sFullFileName),"image/GIF",TRUE,FALSE,TRUE,TRUE,TRUE 
            &nbsp;<BR>set &nbsp;fso=nothing &nbsp;<BR>set 
            &nbsp;m_m_cspace=nothing &nbsp;<BR>set &nbsp;m_cht=nothing 
            &nbsp;<BR>%&gt; &nbsp;<BR>&nbsp;<BR>&lt;br/&gt;&lt;br/&gt; 
            &nbsp;<BR>&nbsp;<BR>&lt;/BODY&gt; &nbsp;<BR>&lt;/HTML&gt; 
            &nbsp;<BR>&nbsp;<BR>折线图 &nbsp;<BR>&lt;%@ &nbsp;Language=VBScript 
            &nbsp;%&gt; &nbsp;<BR>&lt;% &nbsp;<BR>Option &nbsp;Explicit 
            &nbsp;<BR>&nbsp;<BR>&nbsp;<BR>'页面级对象 &nbsp;<BR>'-------------------- 
            &nbsp;<BR>Dim &nbsp;m_cn &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;'链接对象 &nbsp;<BR>Dim &nbsp;m_rs &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;'记录集对象 &nbsp;<BR>Dim &nbsp;m_cspace &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp;'OWC.ChartSpace &nbsp;object &nbsp;<BR>Dim 
            &nbsp;m_fso &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;'文件系统对象 
            &nbsp;<BR>Dim &nbsp;m_objBinaryFile &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp;'二进值文件流对象 &nbsp;<BR>&nbsp;<BR>Dim &nbsp;m_sYear &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp;'需要查询的年份 &nbsp;<BR>&nbsp;<BR>Dim &nbsp;sSQL 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'执行的SQL &nbsp;语句 
            &nbsp;<BR>Dim &nbsp;c &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp;'OWC &nbsp;常量对象 &nbsp;<BR>Dim &nbsp;cht 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'图表临时参考变量 
            &nbsp;<BR>Dim &nbsp;ax &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp;'数轴的临时参考变量 &nbsp;<BR>Dim &nbsp;fnt &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'OWCFont字体的临时参考变量 
            &nbsp;<BR>Dim &nbsp;sFullFileName &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp;'输出GIF文件的临时参考路径 &nbsp;<BR>&nbsp;<BR>'获得查询年份,缺省为2002 
            &nbsp;<BR>m_sYear &nbsp;= &nbsp;Request.QueryString("year") 
            &nbsp;<BR>if &nbsp;len(m_sYear) &nbsp;= &nbsp;0 &nbsp;then 
            &nbsp;m_sYear &nbsp;= &nbsp;"2002" 
            &nbsp;<BR>&nbsp;<BR>'创建一个ADO链接和记录集对象 &nbsp;<BR>set &nbsp;m_cn 
            &nbsp;= &nbsp;Server.CreateObject("ADODB.Connection") &nbsp;<BR>set 
            &nbsp;m_rs &nbsp;= &nbsp;Server.CreateObject("ADODB.Recordset") 
            &nbsp;<BR>&nbsp;<BR>'链接到Access数据库,使用客户端的游标引擎打开记录集 
            &nbsp;<BR>m_cn.Open &nbsp;"provider=microsoft.jet.oledb.4.0;data 
            &nbsp;source=" &nbsp;&amp; &nbsp;Server.MapPath(".") &nbsp;&amp; 
            &nbsp;"\data.mdb" &nbsp;<BR>sSQL &nbsp;= &nbsp;"SELECT 
            &nbsp;Month([OrderDate]) &nbsp;AS &nbsp;[Month], 
            &nbsp;Invoices.Salesperson, &nbsp;" &nbsp;&amp; &nbsp;_ 
            &nbsp;<BR>&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;"Sum(Invoices.ExtendedPrice) &nbsp;AS &nbsp;Sales 
            &nbsp;FROM &nbsp;Invoices &nbsp;" &nbsp;&amp; &nbsp;_ 
            &nbsp;<BR>&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;"WHERE 
            &nbsp;Invoices.OrderDate &nbsp;between &nbsp;#1/1/" &nbsp;&amp; 
            &nbsp;m_sYear &nbsp;&amp; &nbsp;"# &nbsp;and &nbsp;#12/31/" 
            &nbsp;&amp; &nbsp;m_sYear &nbsp;&amp; &nbsp;"# &nbsp;" &nbsp;&amp; 
            &nbsp;_ &nbsp;<BR>&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
            &nbsp;&nbsp;"GROUP &nbsp;BY &nbsp;Month([OrderDate]), 
            &nbsp;Invoices.Salesperson" &nbsp;<BR>m_rs.CursorLocation &nbsp;= 
            &nbsp;3 &nbsp;'adUseClient &nbsp;<BR>m_rs.Open &nbsp;sSQL, 
            &nbsp;m_cn, &nbsp;3 &nbsp;'adOpenStatic 
            &nbsp;<BR>&nbsp;<BR>'增加一个带有图例的簇列图表 &nbsp;<BR>set &nbsp;m_cspace 
            &nbsp;= &nbsp;server.CreateObject("OWC.Chart") &nbsp;<BR>set 
            &nbsp;m_cspace.DataSource &nbsp;= &nbsp;m_rs &nbsp;<BR>set &nbsp;cht 
            &nbsp;= &nbsp;m_cspace.Charts.Add() &nbsp;<BR>set &nbsp;c &nbsp;= 
            &nbsp;m_cspace.Constants &nbsp;<BR>&nbsp;<BR>cht.HasLegend &nbsp;= 
            &nbsp;True &nbsp;<BR>&nbsp;<BR>cht.Type 
            &nbsp;=c.chChartTypeLineMarkers &nbsp; 
            &nbsp;<BR>'设置图表的数据源,把销售人添加到序列名称,销售月份添加到分类组,销售金额作为图表中各项取值 
            &nbsp;<BR>&nbsp;<BR>&nbsp;<BR>cht.SetData &nbsp;c.chDimSeriesNames, 
            &nbsp;0, &nbsp;"Salesperson" &nbsp;<BR>cht.SetData 
            &nbsp;c.chDimCategories, &nbsp;0, &nbsp;"Month" 
            &nbsp;<BR>cht.SetData &nbsp;c.chDimValues, &nbsp;0, &nbsp;"Sales" 
            &nbsp;<BR>&nbsp;<BR>&nbsp;<BR>cht.SeriesCollection(4).Interior.Color 
            &nbsp;= &nbsp;"blue" &nbsp;'改变第四条线的颜色为蓝色 
            &nbsp;<BR>Cht.SeriesCollection(4).Line.Color &nbsp;= &nbsp;"blue" 
            &nbsp;<BR>&nbsp;<BR>&nbsp;<BR>'增加一个图表标题,并格式化标题 
            &nbsp;<BR>cht.HasTitle &nbsp;= &nbsp;True 
            &nbsp;<BR>cht.Title.Caption &nbsp;= &nbsp; &nbsp; &nbsp;m_sYear 
            &nbsp;&amp; &nbsp;"的销售金额 &nbsp;" &nbsp;<BR>set &nbsp;fnt &nbsp;= 
            &nbsp;cht.Title.Font &nbsp;<BR>fnt.Name &nbsp;= &nbsp;"宋体" 
            &nbsp;<BR>fnt.Size &nbsp;= &nbsp;10 &nbsp;<BR>fnt.Bold &nbsp;= 
            &nbsp;True &nbsp;<BR>&nbsp;<BR>'对分类轴添加标题,并格式化标题 &nbsp;<BR>set 
            &nbsp;ax &nbsp;= &nbsp;cht.Axes(c.chAxisPositionBottom) 
            &nbsp;<BR>ax.HasTitle &nbsp;= &nbsp;True &nbsp;<BR>ax.Title.Caption 
            &nbsp;= &nbsp;"月份" &nbsp;<BR>set &nbsp;fnt &nbsp;= 
            &nbsp;ax.Title.Font &nbsp;<BR>fnt.Name &nbsp;= &nbsp;"宋体" 
            &nbsp;<BR>fnt.Size &nbsp;= &nbsp;8 &nbsp;<BR>fnt.Bold &nbsp;= 
            &nbsp;True &nbsp;<BR>&nbsp;<BR>'对数值轴添加标题,并格式化标题 &nbsp;<BR>set 
            &nbsp;ax &nbsp;= &nbsp;cht.Axes(c.chAxisPositionLeft) 
            &nbsp;<BR>ax.NumberFormat &nbsp;= &nbsp;"Currency" 
            &nbsp;<BR>ax.HasTitle &nbsp;= &nbsp;True 
        &nbsp;<BR>ax<BR></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR>
<TABLE align=center border=0 cellPadding=2 cellSpacing=0 id=footer width=770>
  <TBODY>
  <TR>
    <TD align=middle class=tdt>
      <P align=center></P></TD></TR></TBODY></TABLE><BR></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -