I am using the ExcelDataReaderFactory
in C#, in order to read my Excel files and inserting them to a database.
Right now I am specifying sheetname
I don't know that library. But I think you are converting it to a DataSet
anyway. Then the first sheet/table is:
DataTable firstWorkSheet = reader.AsDataSet().Tables[0];
Since the indexer of DataTableCollection has an overload for the index not only for the name.
So the whole method is:
public IEnumerable GetFirstSheetData(bool firstRowIsColumnNames = false)
{
var reader = this.getExcelReader();
reader.IsFirstRowAsColumnNames = firstRowIsColumnNames;
return reader.AsDataSet().Tables[0].AsEnumerable();
}