[已解決] 關於 Excel2003 的問題
該問題在 VB6 論壇發表了, 但是一整天都沒有得到解決, 只好放到 ASP 裏面了, 希望可以得到解決:(其實也是 ASP 的問題)..
=============================================================================
Excel 文件 Book1.xls 存放在:\Book1.xls
裏面有 3 個 Sheet: Sheet1, Sheet2 和 Sheet3
其中 Sheet1 的內容如下:
row(0,0) | row(0,1) |
row(1,0) | row(1,1) |
row(2,0) | row(2,2) |
代碼片斷:(VBScript 格式的)
Dim hConn, hCmd, hRds
Set hConn = Server.CreateObject("ADODB.Connection")
Set hCmd = Server.CreateObject("ADODB.Command")
hConn.Open "Driver={Microsoft Excel Driver (*.xls)};DBQ=" & Server.MapPath("\Book1.xls")
Set hCmd.ActiveConnection = hConn
hCmd.CommandText = "SELECT * FROM [Sheet1$]"
Set hRds = hCmd.Execute
Response.Write "<TABLE Border=""1"">" & vbCrLf
Do While Not hRds.EOF
Response.Write "<TR><TD>" & hRds(0).Value & "</TD>" & _
"<TD>" & hRds(1).Value & "</TD>" & "</TR>" & vbCrLf
hRds.MoveNext
Loop
hCmd.CommandText = "SELECT COUNT(*) FROM [Sheet1$]"
Set hRds = hCmd.Execute
Response.Write "<TR><TD>Count of the recordset: " & hRds(0) & "</TD></TR>"
Response.Write "</TABLE>"
hConn.Close
Set hCmd = Nothing
Set hConn = Nothing
============================================================================
Web 頁面的執行結果:
row(1,0) | row(1,1) |
row(2,0) | row(2,2) |
Count of the recordset: 2 |
============================================================================
問題: 爲甚麽不能得到表中第一條記錄,?
===>(注: 在 Excel2000 中可以得到的結果集, 但是在 Excel2003 則反之.)
===>操作環境: WindowsXP SP2, IIS6, Excel2003(非全新安裝, 是由 Office2000 升級過來的)
[此贴子已经被作者于2006-7-21 1:36:27编辑过]