正在加载中...
信息详页
返回ASP如何连接Excel文件,读取其中的数据
<% Dim xlsName, conn, rs, SQL xlsName = "test.xls" Set conn = Server.CreateObject("ADODB.Connection") conn.Open "Driver={Microsoft Excel Driver (*.xls)};ReadOnly=0;DBQ=" & Server.MapPath(xlsName) SQL = "select * from [sheet1$]" Set rs = Server.CreateObject("ADODB.Recordset") rs.Open SQL, conn, 1, 3 Response.Write "<table border=1>" Do While Not rs.Eof Response.Write "<tr>" for i=0 to rs.Fields.Count-1 Response.Write "<td>" & Trim(rs(i)) & "</td>" Next Response.Write "</tr>" rs.MoveNext Loop Response.Write "</table>" rs.Close conn.Close Set rs = nothing Set conn = nothing %>