asp如何查询数据并导出这表查询出的数据为excel

Rokudo 发布于 2013/12/03 08:14
阅读 821
收藏 0
加载中
0
台湾
台湾
<%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"%>
Rokudo
Rokudo
这个方法我试过了,很不完善的
返回顶部
顶部