使用asp脚本将access的数据转移到excel
在整理资料的时候发现有一个文件:AccessToExcel.asp文件,看了一下内容,大概是将一个表里的数据转移到excel。
现贴出代码:
<%
xlsStr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("stockList.xls") & ";Extended Properties=Excel 8.0"
set cnXLS =server.createobject("ADODB.Connection")
cnXLS.Open xlsStr
set cnDB = Server.CreateObject("ADODB.CONNECTION")
cnDB.open "Provider=Microsoft.jet.oledb.4.0; Data Source="&Server.MapPath("asp_bin/data/data.mdb")
set xlsRead = Server.createobject("adodb.Recordset")
xlsRead.open "select * from [Sheet1$]",cnXLS,1,1
set dbRead=server.createobject("adodb.Recordset")
dbRead.open "select * from products",cnDB,1,3
do until xlsRead.eof
i=i+1
dbRead.addnew
dbRead("PartNo")=xlsRead("PartNo")
dbRead("Manufactrue")=xlsRead("Manufactrue")
dbRead("Datecode")=xlsRead("Datecode")
dbRead("Package")=xlsRead("Package")
dbRead("Quantity")=xlsRead("Quantity")
dbRead("Describe")=xlsRead("Describe")
dbRead("Brand")=xlsRead("Brand")
dbRead("D/C")=xlsRead("D/C")
dbRead("Quotations")=xlsRead("Quotations")
dbRead("State")=xlsRead("State")
xlsRead.MoveNext
loop
dbRead.update
%>
<script language="javascript">alert('已经执行到这儿了。\n 共执行了<%=i%>次。');</script>