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

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

📁 较为详细的介绍了asp自定义的各种函数,方便asp的各种开发.
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0055)http://www.51base.com/article/view_article.asp?id=72419 -->
<HTML lang=zh-cn><HEAD><TITLE>NB联盟</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type><LINK 
href="NB联盟29.files/style.css" rel=stylesheet>
<META content="MSHTML 5.00.2614.3500" name=GENERATOR></HEAD>
<BODY><!-- start page body -->
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 class=td id=position 
width=773>
  <TBODY>
  <TR>
    <TD class=shadow colSpan=2 height=20 width=262>&nbsp;&nbsp;<A 
      href="http://www.51base.com/"><IMG border=0 
      src="NB联盟29.files/logo1.gif"></A> </TD>
    <TD align=right width=505>
      <P align=left></P></TD></TR></TBODY></TABLE>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 id=main width=770>
  <TBODY>
  <TR>
    <TD class=tdlbr vAlign=top>
      <TABLE align=center border=0 cellPadding=0 cellSpacing=0 id=welcome 
      style="TABLE-LAYOUT: fixed" width="98%">
        <TBODY>
        <TR>
          <TD style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all" 
            vAlign=top><FONT color=red><B>文章标题</B></FONT><FONT color=red><B>: 
            在ASP中怎樣用Excel寫報表? </B></FONT>
            <HR noShade SIZE=1>
            <BR>在ASP中﹐怎樣將Sql 
            &nbsp;Server或者Oracle數據庫的資料轉成Excel圖表(直條圖和折線圖)﹐并在網頁顯示出來? 
            &nbsp;<BR>最好有實例。 
            &nbsp;<BR>--------------------------------------------------------------- 
            &nbsp;<BR>&nbsp;<BR>http://www.csdn.net/Subject/15/index.shtm 
            &nbsp;<BR>--------------------------------------------------------------- 
            &nbsp;<BR>&nbsp;<BR>OWC,具体使用可以看OFFICE安装目录下2052里的MSOWC.CHM 
            &nbsp;<BR>&nbsp;<BR>柱图 &nbsp;<BR>&lt;%@ &nbsp;Language=VBScript 
            &nbsp;%&gt; &nbsp;<BR>&lt;% &nbsp;<BR>Option &nbsp;Explicit 
            &nbsp;<BR>'Response.Expires &nbsp;= &nbsp;-1 
            &nbsp;<BR>'Response.ContentType &nbsp;= &nbsp;"image/gif" 
            &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;cht &nbsp;= &nbsp;m_cspace.Charts.Add() &nbsp;<BR>set &nbsp;c 
            &nbsp;= &nbsp;m_cspace.Constants &nbsp;<BR>&nbsp;<BR>set 
            &nbsp;m_cspace.DataSource &nbsp;= &nbsp;m_rs 
            &nbsp;<BR>&nbsp;<BR>cht.Type &nbsp;= &nbsp;1 &nbsp;<BR>cht.HasLegend 
            &nbsp;= &nbsp;True 
            &nbsp;<BR>&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>c.HasPercentage &nbsp;= &nbsp;True &nbsp;<BR>c.HasValue 
            &nbsp;= &nbsp;False &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.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>fnt.color="red" 
            &nbsp;<BR>&nbsp;<BR>'用一个临时变量名保存当前文件,这个文件名是唯一的 &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>'使用 &nbsp;On &nbsp;Error 
            &nbsp;Resume &nbsp;Next语句是为了确保我们删除了临时文件,即使一些函数调用失败 &nbsp;<BR>on 
            &nbsp;error &nbsp;resume &nbsp;next 
            &nbsp;<BR>&nbsp;<BR>'GIF文件已经输出,我们可以通过COM组件把它的内容发送到客户端 &nbsp;<BR>set 
            &nbsp;m_objBinaryFile &nbsp;= 
            &nbsp;server.CreateObject("BinFileWrite.GetFileStream") 
            &nbsp;<BR>&nbsp;<BR>m_objBinaryFile.SendBinFile 
            &nbsp;CStr(sFullFileName),"image/GIF",TRUE,FALSE,TRUE,TRUE,TRUE 
            &nbsp;<BR>'GIF文件已经不需要了可以删除了 &nbsp;<BR>m_objBinaryFile.DeleteFile 
            &nbsp;CStr(sFullFileName) &nbsp;<BR>&nbsp;<BR>%&gt; 
            &nbsp;<BR>&nbsp;<BR>饼图 &nbsp;<BR>&lt;%@ &nbsp;Language=VBScript 
            &nbsp;%&gt; &nbsp;<BR>&nbsp;<BR>&lt;html&gt; 
            &nbsp;<BR>&nbsp;<BR>&lt;head&gt; &nbsp;<BR>&lt;meta 
            &nbsp;name="GENERATOR" &nbsp;content="Microsoft &nbsp;FrontPage 
            &nbsp;4.0"&gt; &nbsp;<BR>&lt;meta &nbsp;name="ProgId" 
            &nbsp;content="FrontPage.Editor.Document"&gt; 
            &nbsp;<BR>&lt;title&gt;利用OWC动态生成图表&lt;/title&gt; 
            &nbsp;<BR>&lt;/head&gt; &nbsp;<BR>&nbsp;<BR>&lt;body&gt; 
            &nbsp;<BR>&lt;% &nbsp;<BR>set &nbsp;m_cspace &nbsp;= 
            &nbsp;server.CreateObject("OWC.Chart") &nbsp;<BR>set &nbsp;DSC 
            &nbsp;= &nbsp;server.CreateObject("OWC.DataSourceControl") 

⌨️ 快捷键说明

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