Set conn=Server.CreateObject("ADODB.Connection")
StrConn="Driver={Microsoft Excel Driver (*.xls)};DriverId=790; DBQ="& realpath
conn.Open StrConn
Set rs = Server.CreateObject("ADODB.Recordset")
Sql="select * from [Sheet1$]"
rs.Open Sql,conn,2,2
set Columns=rs.Fields
ColCount=Columns.Count '獲得字段數(shù)
do while Not rs.EOF
'預(yù)留判斷
rs(0)
rs(1)
rs(2)
或者
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
("test.xls")
更多信息請查看IT技術(shù)專欄