I've highlighted the things which I want to read separately, in dataTables , if possible.
I've used Following code but it only works when there is only one table is present in the sheet.
I've used Following code but it only works when there is only one table is present in the sheet.
Code
public DataSet ReadXlsx(string filepath)Code
tryCode
{Code
FileStream stream = File.Open(filepath, FileMode.Open, FileAccess.Read);Code
//2. Reading from a OpenXml Excel file (2007 format; *.xlsx)Code
IExcelDataReader excelReader2 = ExcelReaderFactory.CreateOpenXmlReader(stream);Code
//... //4. DataSet - Create column names from first rowCode
excelReader2.IsFirstRowAsColumnNames = true;Code
DataSet result2 = excelReader2.AsDataSet(); return result2;Code
}Code
catch (Exception ex)Code
{Code
return null;Code
}Code
}Code
Please help. Thanks.
Vishal JadavRank #1,692 · 901 reputationPosted Sep 19, 2016, 6:22 AM EDT