asp读取excel例子
2014-08-26来源:易贤网

<%

Dim objConn,objRS

Dim strConn,strSql

dim lRecCount

set objConn=Server.CreateObject("ADODB.Connection")

set objRS=Server.CreateObject("ADODB.Recordset")

strConn="Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 8.0;Data Source=" & server.mappath("execel/857/20090610115239.xls")

objConn.Open strConn

strSql="SELECT * FROM [Sheet1$]"

objRS.Open strSql,objConn,1,1

lRecCount=objRS.RecordCount

response.write "数据总数:" & CStr(lRecCount) & "<br>"

objRS.MoveFirst

while not objRS.eof

response.write objRS(0) & "----" & objRS(1) & "-------" & objRS(2) & "-------" & objRS(3) & "-------" & objRS(4)& "-------" & objRS(5)& "-------" & objRS(6)& "-------" & objRS(7) &"-------" & objRS(8)& "<br>"

objRS.MoveNext

wend

objRS.Close

objConn.Close

set objRS = Nothing

set objConn = Nothing

%>

更多信息请查看IT技术专栏

推荐信息