日期:2014-05-17  浏览次数:22290 次

关于ASP网页的列(从数据库表中查询出来的数据)怎么导出EXCEL?
最好能倒成多表头的,我现在一点思路都没有?
谢谢大家指教。
我光听说要下载个什么控件,但是我不知道

------解决方案--------------------
给个我的例子你看看,注意目录iis用户要有读写权限,store_Main1.xls为模板文件,先做好表头
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
strConn = "driver={SQL SERVER};server=(local);uid=sa;pwd=000ppp;database=db_szcrm"
Set Adocn = Server.CreateObject("ADODB.Connection")
Adocn.Open strConn
Set rstOrder = Server.CreateObject("ADODB.Recordset")
rstOrder.CursorLocation = 3
strSqlOrder="select * from para_info"
rstOrder.Open strSqlOrder,Adocn,3,3
intRecordCount=rstOrder.RecordCount 
sSourceXLS = Server.MapPath(".") & "\store_Main1.xls"
sDestXLS = Server.MapPath(".") & "\store_Main.xls" 
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.GetFile(sSourceXLS).Copy sDestXLS
Set fso = Nothing
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & sDestXLS & ";" & _
"Extended Properties=""Excel 8.0;HDR=NO;"""
Set RssExcel = Server.CreateObject("ADODB.Recordset")
rssExcel.open "select * from [sheet1$]" ,oConn,3,3
For iPage = 1 To intRecordCount
rssExcel.addnew
rssExcel(0)=iPage & " "
rssExcel(1)=rstOrder("para_name") & " "
rssExcel(2)=rstOrder("sumCount") & " "
rssExcel(3)=rstOrder("sumAmount") & " "
rssExcel.UpdateBatch
rstOrder.movenext
If rstOrder.EOF Then Exit For
Next
rssExcel.close
set rssExcel=nothing 
Response.Write "<META HTTP-EQUIV=""REFRESH"" Content=""0;URL="+ "store_Main.xls"">"
rstOrder.close
set rstOrder=nothing
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body>

</body>
</html>


------解决方案--------------------
http://blog.csdn.net/scbzdj/article/details/6668674

参考一下这个帖子。
------解决方案--------------------
asp导出excel表格
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "content-disposition", "inline; filename = 文件名.xls"
下面按照常规asp代码书写