Public Sub main()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\book1.xls;Persist Security Info=False;User ID=Admin;Password=;Extended properties=Excel 5.0"
cn.CursorLocation = adUseClient
cn.Open
rs.Open "SELECT * FROM [Sheet1$]", cn, adOpenDynamic, adLockBatchOptimistic
MsgBox rs.RecordCount
rs.MoveFirst
Do While rs.EOF <> True
MsgBox rs.Fields.Item(0).Name
MsgBox rs.Fields.Item(0).Value
rs.MoveNext
Loop
If rs.State <> adStateClosed Then rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub
Dim xlApp As New Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Set xlApp = CreateObject("Excel.Application")
strsource = "c:\excel\book1.xls"(你的文件路径)
Set xlbook = xlApp.Workbooks.Open(strsource)
Set xlsheet = xlbook.Worksheets(1)
string temp=xlsheet.cell(0,0)等等
据可以读出数据来