private List<string> GetExcelSheetName(OleDbConnection connection) { List<string> listSheetNames = new List<string>(); try { DataTable dtSheet = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); foreach (DataRow drSheet in dtSheet.Rows) { if (drSheet["TABLE_NAME"].ToString().Contains("$"))//checks whether row contains '_xlnm#_FilterDatabase' or sheet name(i.e. sheet name always ends with $ sign) { listSheetNames.Add(drSheet["TABLE_NAME"].ToString()); } } } catch (Exception ex) { throw new Exception("Could not read Excel sheet names\nDetails: " + ex.Message); } return listSheetNames; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)