您现在的位置: 军旅同心 >> 读书赏析 >> 学习园地 >> 电脑网络 >> 技术文章 >> 文章正文
利用ASP制作EXECL报表方法(二)
作者:采集员 文章来源:来源于网络 点击数: 更新时间:2005-9-10 13:35:42
ation = CreateObject("Excel.application")
    xlApplication.Visible = False
    xlApplication.Workbooks.Add
    Set xlWorksheet = xlApplication.Worksheets(1)
    xlWorksheet.Cells(1,1).Value = "Year"
    xlWorksheet.Cells(1,1).Interior.ColorIndex = 5    
    xlWorksheet.Cells(1,2).Value = "Region"
    xlWorksheet.Cells(1,2).Interior.ColorIndex = 5
    xlWorksheet.Cells(1,3).Value = "Sales"
    xlWorksheet.Cells(1,3).Interior.ColorIndex = 5
        
    iRow = 2
    If Not oRS.EOF Then
        Do Until oRS.EOF
        For i = 0 To oRS.fields.Count-1
            xlWorksheet.Cells(iRow,i + 1).Value = oRS.fields(i)
            xlWorkSheet.Cells(iRow,i + 1).Interior.ColorIndex = 4
        Next
        iRow = iRow + 1
        oRS.MoveNext
    Loop
    End If
    strFile = GenFileName()
    xlWorksheet.SaveAs Server.MapPath(".") & "" & strFile & ".xls"
    xlApplication.Quit                                                ' Close the Workbook
    Set xlWorksheet = Nothing
    Set xlApplication = Nothing
    Response.Write("Click <A HRef=" & strFile & ".xls>Here</A> to get XLS file")    
End Function
</script>
%>

main.htm

<!-- frames -->
<FRAMESET  ROWS="20%,*">
    <FRAME NAME="Request" SRC="request.html" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="auto" FRAMEBORDER="yes">
    <FRAME NAME="Result" SRC="welcome.html" MARGINWIDTH="10" MARGINHEIGHT="10" SCROLLING="auto" FRAMEBORDER="yes">
</FRAMESET>

request.htm

<html>
<head>
    <title>Sales Report Demo</title>
</head>

<body>

<DIV ALIGN="center"><FONT SIZE="+1">Sales Reporting</FONT></DIV>
<FORM ACTION="runquery.asp" METHOD="POST" target=Result>
    Year <SELECT NAME="Year">
        <OPTION VALUE="ALL">ALL</OPTION>
        <OPTION VALUE="1995">1995</OPTION>
        <OPTION VALUE="1996">1996</OPTION>
        <OPTION VALUE="1997">1997</OPTION>
        <OPTION VALUE="1998">1998</OPTION>
        <OPTION VALUE="1999">1999</OPTION>
        </SELECT>
    &nbsp;        
    Region     <SELECT NAME="Region">
        <OPTION VALUE="ALL">ALL</OPTION>
        <OPTION VALUE="North">North</OPTION>
           <OPTION VALUE="East">East</OPTION>
        <OPTION VALUE="South">South</OPTION>
          <OPTION VALUE="West">West</OPTION>
        </SELECT>
    &nbsp;
    Return Results Using
        <SELECT NAME="ReturnAS">
        <OPTION VALUE="HTML">HTML Table</OPTION>
           <OPTION VALUE="Content">Content Type</OPTION>
           <OPTION VALUE="CSV">CSV</OPTION>
           <OPTION VALUE="Excel">Native Excel</OPTION>
        </SELECT>
    &nbsp;    
    &nbsp;
<INPUT TYPE="Submit" NAME="Submit" VALUE="Submit">                
</FORM>
</body>
</html>

welcome.htm
<html>
<head>
    <title>Sales Report Demo</title>
</head>

<body>



</body>
</html>

数据库结构
testDB.Mdb
表sales
year   数字
Region  文本
Sales_Amt 货币

本文原始出处为国外一网站,并经过BATMAN的休正。

上一页  [1] [2] 


 
免责声明:作品版权归所属媒体与作者所有!!本站刊载此文不代表同意其说法或描述,仅为提供更多信息。如果您认为我们侵犯了您的版权,请告知!本站立即删除。有异议请联系我们。
文章录入:烟灰缸    责任编辑:烟灰缸 
网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
| 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明 | 网站公告 | 管理登录 |