ASP页面中怎么导出Excel文档
发布网友
发布时间:2022-04-20 21:16
我来回答
共1个回答
热心网友
时间:2023-09-06 06:10
<%rs.open "select * from [table]",conn,1,1
if not rs.eof then
set fso=server.createObject("scripting.fileSystemObject")
filename=Server.MapPath("online.xls")
if fso.FileExists(filename) then
fso.DeleteFile(filename)
end if
set myfile = fso.CreateTextFile(filename,true)
dim strLine,responsestr
For each x in rs.fields
strLine= strLine & x.name & chr(9)
Next
myfile.writeline strLine
Do while Not rs.EOF
for each x in rs.Fields
strLine= strLine & x.value & chr(9)
next
myfile.writeline strLine
rs.MoveNext
loop
myfile.writeline ()
end if
rs.close
response.redirect "online.xls"%>