设为首页收藏本站

Scripts 学盟

 找回密码
 加入学盟

QQ登录

只需一步,快速开始

查看: 874|回复: 0
打印 上一主题 下一主题

asp将sql数据导成excel,网上找的都会乱码,不知道为什么,改了编码还是一样。我现在 [复制链接]

管理员

超级大菜鸟

Rank: 9Rank: 9Rank: 9

1#
混混@普宁.中国 实名认证  发表于 2013-5-31 22:38:26 |显示全部楼层
1.  下载 http://www.iscripts.org/sct/org/ ... ordsetConverter.sct

2. 建立 access 数据库 db.mdb

3. 下面代码保存为 export.asp
<%@ language="VBScript" codepage="65001" %>
<%
Response.CodePage = 65001
Response.CharSet = "UTF-8"
Response.LCID = 2052
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment; filename=myTab.xls";

Dim conn, rs, converter
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("db.mdb")

Set rs = conn.Execute("SELECT * FROM myTab")
Set converter = GetObject("script:" & Server.MapPath("RecordsetConverter.sct"))  

Response.Write converter.toXLS(rs)

Set converter = Nothing
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing

%>


export.asp, RecordsetConverter.sct, db.mdb 放在同一目录

访问 export.asp

使用道具 举报

您需要登录后才可以回帖 登录 | 加入学盟

手机版|Scripts 学盟   |

GMT+8, 2024-5-5 08:39 , Processed in 1.056106 second(s), 11 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部