asp 导出excel表格,要有两个页面。 50
导出效果要这样的,目前我找到的代码都是导出单页面。目前用的代码!<%dims,sql,filename,fs,myfile,x,filename2,ExcelApp,eB...
导出效果要这样的,目前我找到的代码都是导出单页面。目前用的代码!
<%
dim s,sql,filename,fs,myfile,x,filename2,ExcelApp,eBook
Set fs = server.CreateObject("scripting.filesystemobject")
filename = Server.MapPath("excel.xls")
if fs.FileExists(filename) then
fs.DeleteFile(filename)
end if
'response.Write(filename)
'response.End()
filename2 = Server.MapPath("excel.xls")
'--创建EXCEL文件
set myfile = fs.CreateTextFile(filename,true)
StartTime = Request("StartTime")
EndTime = Request("EndTime")
StartEndTime = "AddTime between #"& StartTime &" 00:00:00# and #"& EndTime &" 23:59:59#"
strSql = "select * from person order by id desc"
Set rstData = DataToRsStatic(conn,strSql)
if not rstData.EOF and not rstData.BOF then
dim trLine,responsestr
strLine = "序号" & chr(9) & "客户简称" & chr(9) & "单据日期"
myfile.writeline strLine
Do while Not rstData.EOF
strLine=""
strLine = rstData("id") & chr(9) & rstData("yhmbz") & chr(9) & formatdate(rstData("wtime")) & chr(9) & IfSendStr
myfile.writeline strLine
rstData.MoveNext
loop
end if
Response.Write "<br><br> 生成EXCEL文件成功,点击<a href=""excel.xls"" target=""_blank"">下载</a>!"
rstData.Close
set rstData = nothing
Conn.Close
Set Conn = nothing
Function DataToRsStatic(Conn,strSql)
Dim RsStatic
Set DataToRsStatic = Nothing
If Conn Is Nothing Then
Exit Function
End If
Set RsStatic = CreateObject("ADODB.RecordSet")
RsStatic.CursorLocation = 3
RsStatic.Open strSql,Conn,3,3
If Err.Number <> 0 Then
Exit Function
End If
Set DataToRsStatic = RsStatic
End Function
%> 展开
<%
dim s,sql,filename,fs,myfile,x,filename2,ExcelApp,eBook
Set fs = server.CreateObject("scripting.filesystemobject")
filename = Server.MapPath("excel.xls")
if fs.FileExists(filename) then
fs.DeleteFile(filename)
end if
'response.Write(filename)
'response.End()
filename2 = Server.MapPath("excel.xls")
'--创建EXCEL文件
set myfile = fs.CreateTextFile(filename,true)
StartTime = Request("StartTime")
EndTime = Request("EndTime")
StartEndTime = "AddTime between #"& StartTime &" 00:00:00# and #"& EndTime &" 23:59:59#"
strSql = "select * from person order by id desc"
Set rstData = DataToRsStatic(conn,strSql)
if not rstData.EOF and not rstData.BOF then
dim trLine,responsestr
strLine = "序号" & chr(9) & "客户简称" & chr(9) & "单据日期"
myfile.writeline strLine
Do while Not rstData.EOF
strLine=""
strLine = rstData("id") & chr(9) & rstData("yhmbz") & chr(9) & formatdate(rstData("wtime")) & chr(9) & IfSendStr
myfile.writeline strLine
rstData.MoveNext
loop
end if
Response.Write "<br><br> 生成EXCEL文件成功,点击<a href=""excel.xls"" target=""_blank"">下载</a>!"
rstData.Close
set rstData = nothing
Conn.Close
Set Conn = nothing
Function DataToRsStatic(Conn,strSql)
Dim RsStatic
Set DataToRsStatic = Nothing
If Conn Is Nothing Then
Exit Function
End If
Set RsStatic = CreateObject("ADODB.RecordSet")
RsStatic.CursorLocation = 3
RsStatic.Open strSql,Conn,3,3
If Err.Number <> 0 Then
Exit Function
End If
Set DataToRsStatic = RsStatic
End Function
%> 展开
2个回答
2015-07-08 · 知道合伙人数码行家
关注
展开全部
比较难,导出到EXCEL功能,一般都是导出当前的数据到ECXEL,你是想把当前的数据导出到多个分表里吗?
更多追问追答
追问
是的,需要2个分表
追答
直接导出两个EXCEL表不行吗?分表的意义好像也不大
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你这个创建的时普通的文本文件,根本不是EXCLE文件,所以没办法出两个sheet
追问
有什么办法可以 出2个 sheet
追答
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询