2013-08-27
展开全部
给你段代码:<%
strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("数据库.mdb")
set conn = server.createobject("adodb.connection")
conn.open strconn
%>
<HTML>
<HEAD>
<meta content="text/html; charset=gb2312" http-equiv="Content-Type">
<TITLE>生成EXCEL文件</TITLE>
</HEAD>
<body>
<a href="?act=make">在线生成EXCEL</a>
<a href="record.xls" target="_blank">下载</a>
<hr size=1 align=left width=300px>
<%
if Request("act") = "" then
Response.Write "生成EXCEL文件"
elsedim rs,sql,filename,fs,myfile,x
Set fs = server.CreateObject("scripting.filesystemobject")
filename = Server.MapPath("record.xls")
if fs.FileExists(filename) then
fs.DeleteFile(filename)
end ifset myfile = fs.CreateTextFile(filename,true)Set rs = Server.CreateObject("ADODB.Recordset")
sql = "select * from record worder by id desc"
rs.Open sql,conn,1,1
if rs.EOF and rs.BOF thenelse
dim strLine,responsestr
strLine=""
For each x in rs.fields
strLine = strLine & x.name & chr(9)
Next
myfile.writeline strLine
Do while Not rs.EOF
strLine=""
for each x in rs.Fields
strLine = strLine & x.value & chr(9)
next
myfile.writeline strLine
rs.MoveNext
loop
end if
rs.Close
set rs = nothing
End If
%>
strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("数据库.mdb")
set conn = server.createobject("adodb.connection")
conn.open strconn
%>
<HTML>
<HEAD>
<meta content="text/html; charset=gb2312" http-equiv="Content-Type">
<TITLE>生成EXCEL文件</TITLE>
</HEAD>
<body>
<a href="?act=make">在线生成EXCEL</a>
<a href="record.xls" target="_blank">下载</a>
<hr size=1 align=left width=300px>
<%
if Request("act") = "" then
Response.Write "生成EXCEL文件"
elsedim rs,sql,filename,fs,myfile,x
Set fs = server.CreateObject("scripting.filesystemobject")
filename = Server.MapPath("record.xls")
if fs.FileExists(filename) then
fs.DeleteFile(filename)
end ifset myfile = fs.CreateTextFile(filename,true)Set rs = Server.CreateObject("ADODB.Recordset")
sql = "select * from record worder by id desc"
rs.Open sql,conn,1,1
if rs.EOF and rs.BOF thenelse
dim strLine,responsestr
strLine=""
For each x in rs.fields
strLine = strLine & x.name & chr(9)
Next
myfile.writeline strLine
Do while Not rs.EOF
strLine=""
for each x in rs.Fields
strLine = strLine & x.value & chr(9)
next
myfile.writeline strLine
rs.MoveNext
loop
end if
rs.Close
set rs = nothing
End If
%>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-08-27
展开全部
把你要生成exl的ASP页面里增加这段代码就可以了,然后重新访问这个页面就直接会出来exl表格了Application.ScreenUpdating = True '屏幕刷新关闭
Application.DisplayAlerts = True '信息警告开启
Response.ContentType = "application/vnd.ms-excel"
Application.DisplayAlerts = True '信息警告开启
Response.ContentType = "application/vnd.ms-excel"
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-08-27
展开全部
http://hi.baidu.com/zz95zz/blog/category/%B1%E0%B3%CC%BF%AA%B7%A2 毕业后很久没编程了,都忘得差不多了,网上参考下吧。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询