2024年6月21日发(作者:)
asp数据库数据生成excel文件:
<%
if Request("act") = "" then
"生成EXCEL文件实例"
else
dim conn,strconn
strconn="driver={SQL Server};server=wen;uid=sa;pwd=;database=DB_Test"
set conn=Object("tion")
strconn
dim rs,sql,filename,fs,myfile,x
Set fs = Object("stemobject")
'--假设你想让生成的EXCEL文件做如下的存放
filename = h("")
'--如果原来的EXCEL文件存在的话就删除
if ists(filename) then
File(filename)
end if
'--创建EXCEL文件
set myfile = TextFile(filename,true)
Set rs = Object("set")
'--从数据库中把你想放到EXCEL中的数据读出来
sql = "select * from Tb_Execl order by id desc"
sql,conn,1,1
if and then
else
dim strLine,responsestr
strLine=""
For each x in
strLine = strLine & & chr(9)
Next
'--将表的列名先写入EXCEL
ine strLine
Do while Not
strLine=""
for each x in
strLine = strLine & & chr(9)
next
'--将表的数据写入EXCEL
ine strLine
xt
loop
end if
set rs = nothing
End If
%>
以上信息更具具体情况修改
发布者:admin,转转请注明出处:http://www.yc00.com/news/1718941647a2753734.html
评论列表(0条)