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 |