You can read Excel files in .xls and .xlsx extensions using NPOI, you only need to add the following in the usage section
using NPOI.HSSF.UserModel; using NPOI.HPSF; using NPOI.POIFS.FileSystem; using NPOI.XSSF.UserModel; using NPOI.SS.UserModel;
The main thing is that you open the file, you must distinguish between extensions to use the appropriate component, and use the ISheet interface so that you can link to the sheet regardless of the file extension
Once you have an excel object, you only need to read it (null values ββare set in the rows and columns of the NPOI)
To read valer cells, you can use the .ToString () method or the StringCellValue property, but be careful that StringCellValue only works with string cells, and date and number cells throw an exception.
source share