在asp程序中打印excel表格的新方法
來源:易賢網(wǎng) 閱讀:1215 次 日期:2014-11-20 10:11:38
溫馨提示:易賢網(wǎng)小編為您整理了“在asp程序中打印excel表格的新方法”,方便廣大網(wǎng)友查閱!

在asp程序中打印excel報表的新方法

目前,b/s模式(瀏覽器/服務器模式)成為企業(yè)網(wǎng)上首選的計算模式。由于b/s模式的特殊性,在c/s下相對較易實現(xiàn)的excel報表打印功能在b/s下卻成為一個難點。本人通過研究寫了一個基于asp程序的打印excel報表的程序。本程序的特點是無須任何組件。

  

print.asp

------------------------------------------------

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

<%

'控制腳本語言

response.write<script language=&vbscript&>

%>

//*****************本程序由火星工作室提供()******************

//*******************版權(quán)所有 隨意拷貝********************************

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 align=center>

<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>

更多信息請查看IT技術(shù)專欄

更多信息請查看網(wǎng)絡編程
易賢網(wǎng)手機網(wǎng)站地址:在asp程序中打印excel表格的新方法

2025國考·省考課程試聽報名

  • 報班類型
  • 姓名
  • 手機號
  • 驗證碼
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務許可證:(云)人服證字(2023)第0102001523號
聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)