帮忙搞个能用的asp连接excel的代码
搞了几天的excel数据导入到sql还没搞定,怀疑是不是连接excel驱动写法有问题,网上看了几种,都试了不行郁闷。其他自己菜也检查不出啥问题。
<%@ language="jscript" codepage="936" %> <table border="1"> <% var connXls = Server.CreateObject("ADODB.Connection"); connXls.Open("Driver={Microsoft Excel Driver (*.xls)};DBQ=C:\\tab.xls"); var rs = connXls.Execute("SELECT * FROM [工作薄$]"); Response.Write("<tr>"); for (var e = new Enumerator(rs.Fields); !e.atEnd(); e.moveNext()) { var field = e.item(); Response.Write("<th>" + field.Name + "</th>"); } Response.Write("</tr>"); while (!rs.EOF) { Response.Write("<tr>"); for (var e = new Enumerator(rs.Fields); !e.atEnd(); e.moveNext()) { Response.Write("<td>" + e.item().Value + "</td>"); } Response.Write("</tr>"); rs.MoveNext(); } rs.Close(); connXls.Close(); %> </table>