Will NPOI DLL recognize .xlsx
file?
Currently I\'m using NPOI 1.2.5 version DLL for Microsoft Excel 97-2003, but I need to access Excel sheets of exten
May be the library didn't had this feature when the original answer(s) was provided, but now you can handle both xls and xlsx using the same code base without checking for file extensions.
The trick is to use WorkbookFactory class to transparently load both types of files. This will work as long as you are not using special features specific to either version.
using (FileStream fileStream = File.OpenRead(fullPathToExcelFile)) //fullPathToExcelFile can hold either a xls or xlsx, we don't care
{
IWorkbook workbook = WorkbookFactory.Create(fileStream);
ISheet worksheet = workbook.GetSheet("SampleSheet");
//Now read from the worksheet anyway you like
var value = worksheet.GetRow(1).GetCell(1);
}