关于ASP网页的列(从数据库表中查询出来的数据)怎么导出EXCEL?
时间:2011-12-22
来源:互联网
最好能倒成多表头的,我现在一点思路都没有?
谢谢大家指教。
我光听说要下载个什么控件,但是我不知道
谢谢大家指教。
我光听说要下载个什么控件,但是我不知道
作者: brownhwy 发布时间: 2011-12-22
给个我的例子你看看,注意目录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>
<%@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>
作者: zhux2003 发布时间: 2011-12-22
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28