Microsoft Excel ODBC Driver Question

  • Thread starter Thread starter zacks
  • Start date Start date
Z

zacks

Can this driver return to me the names of the active WorkSheets in an
XLS file?
 
On 7 Dec 2005 11:44:36 -0800, (e-mail address removed) wrote:

¤ Can this driver return to me the names of the active WorkSheets in an
¤ XLS file?

Not really no. If you want a list of Excel Worksheets use the Jet OLEDB Provider with the Excel ISAM
driver and GetOleDbSchemaTable:

Dim ExcelConnection As System.Data.OleDb.OleDbConnection
Dim ExcelTables As DataTable

Try

ExcelConnection = New
System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=e:\My Documents\Book10.xls;Extended Properties=Excel 8.0;")

ExcelConnection.Open()

ExcelTables =
ExcelConnection.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, New Object() {Nothing,
Nothing, Nothing})

Dim RowCount As Int32
For RowCount = 0 To ExcelTables.Rows.Count - 1
Console.WriteLine(ExcelTables.Rows(RowCount)!TABLE_NAME.ToString)
Next RowCount

frmMain.DataGrid1.DataSource = ExcelTables

Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
ExcelConnection.Close()

End Try


Paul
~~~~
Microsoft MVP (Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top