当前位置:编程学习 > asp >>

哪个会写asp生成excel表格的代码 要有表头啊

答案:
<%dim excelstring
dim excelstr
dim excelstr2
dim head
excelstring = ""
head = "Sn" & "," & "Reason" & "," & "Empid" & "," & "Empname" & "," & "Ext" & "," & "Depname"
excel="creat"
If excel<>"" Then
Set rs2 = Server.CreateObject ("ADODB.Recordset")
sql2 = "Select * from value_table "
rs2.open sql2,conn,1,3
do while not rs2.eof
excelstr =" " & rs2(0) & """,""" & rs2(1) & """,""" & rs2(2) & """,""" & rs2(3) & """,""" & rs2(4) & """,""" & rs2(5) & """"
excelstr2 = excelstr2 & Chr(13) & excelstr
rs2.movenext
loop
excelstring = head &Chr(13)& excelstr2
'response.Write(excelstring)
'rs2.close
Set rs2=Nothing
set fs = CreateObject("scripting.FileSystemObject")
set exc = fs.OpenTextFile(server.MapPath("excel.csv"),2,True)
exc.write(excelstring)
if fs.FileExists(Server.MapPath("excel.csv")) then
Response.Write("<a href=> 'Response.write(excelstring)
else
Response.Write("生成报表失败!")
end if
End if%>

上一个:为什么箱子地址打开看到的是ASP收信代码?
下一个:怎样生成“首页,下一页,上一页,末页”代码ASP?

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,