using NPOI;
using NPOI.XSSF.UserModel;
using NPOI.SS.UserModel;
using NPOI.HSSF.UserModel;
NPOI.SS.UserModel.IWorkbook excelbook = null;
using (FileStream fs = new FileStream(Path, FileMode.OpenOrCreate, FileAccess.ReadWrite))
{
if (fix == ".xls")
{
excelbook = new HSSFWorkbook(fs);
}
else if (fix == ".xlsx")
{
excelbook = new XSSFWorkbook(fs);
}
ISheet sheet = excelbook.GetSheetAt(0);
for (int i = 1; i < sheet.LastRowNum; i++)
{
IRow row = sheet.GetRow(i);
foreach (var item in row.Cells)
{
item.SetCellType(CellType.String);
}
var data = row.Cells[0].StringCellValue;
var data2 = row.Cells[1].StringCellValue;
}
}