參考引用來源
--
Using m_connexcel As OleDbConnection = New OleDbConnection(String.Format("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source={0};" & _
"Extended Properties=""Excel 8.0;HDR=NO""", SPREADSHEET_NAME))
m_connexcel.Open()
Using cmd As OleDbCommand = New OleDbCommand(String.Format("SELECT * FROM [{0}]", DATARANGE), m_connexcel)
Using oRDR As OleDbDataReader = cmd.ExecuteReader
While (oRDR.Read)
If Not oRDR.IsDBNull(oRDR.GetOrdinal("F1")) Then
MsgBox(oRDR.GetString(oRDR.GetOrdinal("F1")))
End If
End While
End Using
End Using
m_connexcel.Close()
End Using
說明:
Set 'HDR' in the connection string to 'YES' if you want to use the first row as the field names, otherwise the fields will be called
F1, F2, F3 etc...
沒有留言:
張貼留言