When I first asked this question, I thought the problem was that multiple tabs were selected when the file was saved. Opening the file, selecting one tab and then closing the file solved the problem. However, it was opening & saving the file that solved the problem, no the selection of only one tab.
My code to read the XLS file:
- Code: Select all
Dim conn As New OleDbConnection
Dim cmd As New OleDbCommand
Dim dap As OleDbDataAdapter
Dim dt As SampleDataTable
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=""C:\sample.xls"";Extended Properties=""Excel 8.0;"""
cmd.CommandText = "SELECT * FROM [Sample$]"
cmd.Connection = conn
dap = New OleDbDataAdapter(cmd)
With conn
.Open()
dt = new SampleDataTable
dt.Clear()
dap.Fill(dt)
.Close
End With
More info about reading Excel files in VB.NET using OLEDB can be found here: http://www.codeproject.com/KB/office/excel_using_oledb.aspx