using (Stream stream1 = File.OpenRead(Path))
{
IWorkbook workbook = null;
if (ext == ".xlsx")
{
workbook = new XSSFWorkbook(stream1);
}
else
{
workbook = new HSSFWorkbook(stream1);
}
for (int i = 0; i < workbook.NumberOfSheets; i++)
{
ISheet sheet = null;
sheet = workbook.GetSheetAt(i);
for (int j = 2; j <= sheet.LastRowNum; j++)
{
IRow row = sheet.GetRow(j);
Console.WriteLine(row.GetCell(0).StringCellValue);
}
}
}