Here is my code for getting Sheet Names
DataTable dataTable = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
if(dataTable != null)
{
excelSheets = new String[dataTable.Rows.Count];
for(int i = 0; i < dataTable.Rows.Count; i++)
{
excelSheets = dataTable.Rows["TABLE_NAME"].ToString();
}
}
Later on I filter out the ones with just a $. This code works 90% of the time but for some excel files, the sheet names seem to come in a strange order. It is not the order they appear in or the order they were created which is key to my project. Does anyone know why this happens? Also does anyone know of a way to get the Sheet index instead of the Table Name?
DataTable dataTable = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
if(dataTable != null)
{
excelSheets = new String[dataTable.Rows.Count];
for(int i = 0; i < dataTable.Rows.Count; i++)
{
excelSheets = dataTable.Rows["TABLE_NAME"].ToString();
}
}
Later on I filter out the ones with just a $. This code works 90% of the time but for some excel files, the sheet names seem to come in a strange order. It is not the order they appear in or the order they were created which is key to my project. Does anyone know why this happens? Also does anyone know of a way to get the Sheet index instead of the Table Name?