网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的范文:

 

标题 在asp程序中打印excel表格的新方法
范文
    在asp程序中打印excel报表的新方法
    目前,b/s模式(浏览器/服务器模式)成为企业网上首选的计算模式。由于b/s模式的特殊性,在c/s下相对较易实现的excel报表打印功能在b/s下却成为一个难点。本人通过研究写了一个基于asp程序的打印excel报表的程序。本程序的特点是无须任何组件。
    print.asp
    ------------------------------------------------
    <html><title>打印excel报表</title>
    <%
    '控制脚本语言
    response.write<script language=&vbscript&>
    %>
    //*****************本程序由火星工作室提供()******************
    //*******************版权所有 随意拷贝********************************
    function ccprint()
    set xlapp = createobject(excel.application)
    //打开工作表!
    set xlbook = xlapp.workbooks.open(c:book1.xlt)
    set xlsheet1 = xlbook.activesheet
    <% db=zhk.mdb
    set conn = server.createobject(adodb.connection)
    connstr=provider=microsoft.jet.oledb.4.0;data source= & server.mappath(&db&)
    conn.open connstr
    set rsd=server.createobject(adodb.recordset)
    str=select * from cjb00
    rsd.open str,conn
    ii=1
    do while not rsd.eof and ii<11
    %>
    <%response.writexlsheet1.cells(&ii+4&,2).value=%><%=rsd(姓名)%>
    <%response.writexlsheet1.cells(&ii+4&,3).value=%><%=rsd(学号)%>
    <%
    rsd.movenext
    ii=ii+1
    loop
    rsd.close
    set rsd=nothing
    %>
    xlsheet1.application.visible = true
    end function
    //*****************本程序由火星工作室提供******************
    <%
    response.write</script>
    %>
    <html><title>打印excel报表</title>
    <body>
    <center>
    <h2><font color=red>学生表(demo)</font></h2>
    <p>&nbsp;</p>
    <form name=fmp method=post action=>
    <%
    db=zhk.mdb
    set conn = server.createobject(adodb.connection)
    connstr=provider=microsoft.jet.oledb.4.0;data source= & server.mappath(&db&)
    conn.open connstr
    set rsd=server.createobject(adodb.recordset)
    str=select * from cjb00
    rsd.open str,conn
    %>
    <table width=396 height=58 border=1 bordercolor=#00ff00 bgcolor=lightyellow>
    <tr bgcolor=deepskyblue>
    <th><b>姓名</b></th>
    <th><b>学号</b></th>
    </tr>
    <%
    do while not rsd.eof
    %>
    <tr>
    <td> <%=rsd(姓名)%>
    </td>
    <td> <%=rsd(学号)%>
    </td>
    </tr>
    <%
    rsd.movenext
    loop
    %>
    <% rsd.close
    set rsd=nothing
    conn.close
    set cnn=nothing %>
    </table>
    <p>
    <input name=submit2 type=button onclick=ccprint() ondblclick=ccprint() value=打印>
    <br>
    </p>
    </form>
    </center>
    </body>
    </html>
随便看

 

在线学习网范文大全提供好词好句、学习总结、工作总结、演讲稿等写作素材及范文模板,是学习及工作的有利工具。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/20 16:32:34