Z zacks Dec 7, 2005 #1 Can this driver return to me the names of the active WorkSheets in an XLS file?
P Paul Clement Dec 8, 2005 #2 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)
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)