ASP怎样生成Excel表格?
我想在ASP程序里生成一个Excel文件,文件里含有图片和工作表分页,如:含图片的表:工作表分页:请高手帮我写一个完整的程序,最好有注释!...
我想在ASP程序里生成一个Excel文件,文件里含有图片和工作表分页,如:含图片的表: 工作表分页: 请高手帮我写一个完整的程序,最好有 注释!
展开
2个回答
展开全部
<%
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=excel.csv>报表已经生成,点击查看</a>") 'Response.write(excelstring) else Response.Write("生成报表失败!") end if End if%>
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=excel.csv>报表已经生成,点击查看</a>") 'Response.write(excelstring) else Response.Write("生成报表失败!") end if End if%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询