I am trying to get all the tab names that have data from an Excel spreadsheet.
Somewhere I found this code and want to adapt it to loop through all tabs (worksheets) and store it in a drop down combobox:
OleDbConnection dbConnection = new OleDbConnection (@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\SAMPLE.XLS;Extended Properties=""Excel 8.0;HDR=Yes;""");
// Get the name of the first worksheet:
DataTable dbSchema = dbConnection.GetOleDbSchemaTable (OleDbSchemaGuid.Tables, null);
if (dbSchema == null || dbSchema.Rows.Count < 1)
throw new Exception ("Error: Could not determine the name of the first worksheet.");
string SheetNameOne = dbSchema.Rows  ["TABLE_NAME"].ToString ();