you can use given method to get all the sheetnames from an excel file using
oledb
public string[] GetSheetNamesForExcel(string filename)
{
System.Data.DataTable dt = GetDataTable(filename, OleDbSchemaGuid.Tables);
String[] excelSheets = null;
try
{
if (dt != null)
{
excelSheets = new String[dt.Rows.Count];
for (int i = 0; i < dt.Rows.Count; i++)
{
DataRow row = dt.Rows[i];
string name = row["TABLE_NAME"].ToString();
name = name.Replace("'", String.Empty);
name = name.Replace("$", String.Empty);
excelSheets[i] = name;
}
dt.Dispose();
}
}
catch (Exception ex)
{
throw ex;
}
return excelSheets;
}