欢迎光临
我们一直在努力

如何在ASP程序中打印Access报表(无组件的经典程序)

建站超值云服务器,限时71元/月

  目前,b/s模式(浏览器/服务器模式)成为企业网上首选的计算模式。由于b/s模式的特殊性,在c/s下相对较易实现的excel报表打印功能在b/s下却成为一个难点。本人通过研究写了一个基于asp程序的打印acess报表的程序。本程序的特点是无须任何组件。

  

print.asp

————————————————

<html><title>打印excel报表</title>

<%

控制脚本语言

response.write"<script language="&"vbscript"&">"

%>

//*****************本程序由火星工作室提供(andy2001p@hotmail.com)******************

//*******************版权所有 随意拷贝********************************

function ccprint()

set xlapp = createobject("excel.application")

set xlbook = xlapp.workbooks.open("c:\book1.xlt")

set xlsheet1 = xlbook.activesheet

<%

ii=1

do while ii<11

response.write"n"&ii&"=fmp.n"&ii&".value"

%>

//隔一行!

<%response.write"xlsheet1.cells("&ii+4&",2).value=n"&ii%>

//隔一行!

<%response.write"m"&ii&"=fmp.m"&ii&".value"%>

//隔一行!

<%response.write"xlsheet1.cells("&ii+4&",3).value=m"&ii%>

//隔一行!

<%

ii=ii+1

loop%>

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>

<%

n=1

do while not rsd.eof

%>

<tr align=center>

<td>

<input name="<%="n"&n%>" type="hidden" value="<%=rsd("姓名")%>">

<%=rsd("姓名")%>

</td>

<td>

<input name="<%="m"&n%>" type="hidden" value="<%=rsd("学号")%>">

<%=rsd("学号")%>

</td>

</tr>

<%

m=m+1

n=n+1

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>

————————————————————

在程序写好后,你必须在 c 盘根目录下建个excel模板文件! 在ie的安全设置中将安全级别调为最低或自定义安全级别中启用第二项就可以了!

本程序由andylee(火星)提供,如果有意见请联系:

email:andy2001p@hotmail.com

qq:16685104

tel:0595-2092139

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 如何在ASP程序中打印Access报表(无组件的经典程序)
分享到: 更多 (0)

相关推荐

  • 暂无文章