有谁在ASP中这样用过Excel吗?(100分)

  • 主题发起人 笑傲江湖1976
  • 开始时间

笑傲江湖1976

Unregistered / Unconfirmed
GUEST, unregistred user!
set ren=server.CreateObject("excel.application")
生成一个Excel对象,但是该页面执行了很久并且超时了,我想在server端调用Excel的一
些方法,生成Excel文件,然后在客户端打开文件.
 
我做的时候一般是先建一个execl模板,然后在asp里面:
<!--#include file="include/Circket_access.inc"-->
<html><title>打印Excel报表</title>
<%
'控制脚本语言
response.write"<script language="&amp;"VBScript"&amp;">"
%>
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"&amp;ii&amp;"=fmp.n"&amp;ii&amp;".value"
%>
//隔一行!
<%response.write"xlSheet1.cells("&amp;ii+4&amp;",2).value=n"&amp;ii%>
//隔一行!
<%response.write"m"&amp;ii&amp;"=fmp.m"&amp;ii&amp;".value"%>
//隔一行!
<%response.write"xlSheet1.cells("&amp;ii+4&amp;",3).value=m"&amp;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>&amp;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"&amp;n%>" type="hidden" value="<%=rs("ShopName")%>">
<%=rs("ShopName")%>
</td>
<td>
<input name="<%="m"&amp;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>
 
接受答案了.
 
顶部