I am trying to extract the contents of an Excel (11.0) Spreadsheet and display it in a vb.NET gridvew. After the the spreadsheet is loaded in the Gridview I also want to provide the user with the option of uploading the Gridview data to a SQL Server DB.
When I attempt tp execute the attached code I receive the below error:
Exception Details: System.Data.OleDb.OleDbExc
eption: External table is not in the expected format.
I've been struggling with this one for a while so any advice would be greatly appreciated?
Dim gv As New GridView()
Dim DBConnection = New OleDbConnection( _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\ExcelFiles\test.xls;" & _
"Extended Properties=Excel 8.0;")
Dim SQLString As String = "SELECT * FROM [test$]"
Dim DBCommand = New OleDbCommand(SQLString, DBConnection)
Dim DBReader As Data.IDataReader = DBCommand.ExecuteReader()
gv.DataSource = DBReader