设为首页收藏本站

Scripts 学盟

 找回密码
 加入学盟

QQ登录

只需一步,快速开始

查看: 861|回复: 1
打印 上一主题 下一主题

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

跳转到指定楼层
1#
匿名  发表于 2013-5-31 17:09:41 |倒序浏览 | 取消回复通知
asp将sql数据导成excel,网上找的都会乱码,不知道为什么,改了编码还是一样。我现在用的是office2007,是不是跟版本有关,急救
分享到: QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
分享分享0 收藏收藏0

管理员

超级大菜鸟

Rank: 9Rank: 9Rank: 9

2#
混混@普宁.中国 实名认证  发表于 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-4-25 23:53 , Processed in 1.071903 second(s), 11 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部