The code explicitly requests HSSF, so it will only work with the older versions .xls (binary) files.
If you want, you can code POI to auto-detect which file type you have, and pick the appropriate one of HSSF or XSSF for your case. However, to do that you need to change your code slightly, and use interfaces rather than concrete classes (so your code works whether you get a HSSF or XSSF object)
Replace following line of code
NPOI.HSSF.UserModel.HSSFWorkbook hSSFWorkbook = new NPOI.HSSF.UserModel.HSSFWorkbook(ms);
IWorkbook hSSFWorkbook = NPOI.SS.UserModel.WorkbookFactory.Create(ms);
Posted On: 11-Oct-2017 03:51