我做的时候一般是先建一个execl模板,然后在asp里面:
<!--#include file="include/Circket_access.inc"-->
<html><title>打印Excel报表</title>
<%
'控制脚本语言
response.write"<script language="&"VBScript"&">"
%>
function ccprint()
Set xlApp = CreateObject("EXCEL.APPLICATION")
Set xlBook = xlApp.Workbooks.Open("c:/Info/test.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>Shop报表</font></h2>
<p>&nbsp;</p>
<form name="fmp" method="post" action="">
<%
sql="select * from InfoShop order by ShopNo DESC"
rs.open sql,conn,3,2
%>
<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 rs.eof
%>
<tr align=center>
<td>
<input name="<%="n"&n%>" type="hidden" value="<%=rs("ShopName")%>">
<%=rs("ShopName")%>
</td>
<td>
<input name="<%="m"&n%>" type="hidden" value="<%=rs("ShopNo")%>">
<%=rs("ShopNo")%>
</td>
</tr>
<%
m=m+1
n=n+1
rs.MoveNext
loop
%>
<% rs.close
set rs=nothing
%>
</table>
<p>
<input name="Submit2" type="button" onclick="ccprint()" onDblClick="ccprint()" value="打印">
<br/>
</p>
</form>
</center>
</body>
</html>