0

I'm trying to use NPOI to read large excel files. However I have only been able to find examples in which an entire workbook is read into memory at once.

using var stream = new FileStream(src, FileMode.Open);
XSSFWorkbook wb = new(stream);

The memory footprint is quite large when doing this. (8Mb .xls => 1gb of memory when debugging in VS)

Does anyone know if it's possible to use NPOI to ideally read a sheet line by line? Failing that, how to load one single sheet at a time?

Lastly if anyone has any recommendations for other excel file readers (other than using OLEDB), I'd like to hear them!

  • Try [ExcelDataReader](https://github.com/ExcelDataReader/ExcelDataReader) – Magnetron Aug 26 '21 at 19:49
  • Any reason you aren't using OpenXML?https://www.nuget.org/packages/DocumentFormat.OpenXml – Camilo Terevinto Aug 26 '21 at 20:02
  • The `.xls` format is a dog's breakfast, stay away from it. The `.xlsx` format is standardized and more than 10 years old. Not surprisingly, Excel files are not just stuff in row order format. You can find tools that present the data _line by line_, but that's an abstraction over a complex format – Flydog57 Aug 26 '21 at 20:40

0 Answers0