I use the following code to read really large excel files - up to 500k lines with up to 100 columns
public List<ExcelLine> getExcelLines(Path path, int batchSize) {
log.info("Reading excel file");
try (Workbook workbook = WorkbookFactory.create(path.toFile())) {
Sheet sheet = workbook.getSheetAt(0);
...
}
}
The idea was to read by batches to avoid OutOfMemory error and it works for small files. However, once I call the method with large file, I see log.info
statement, but then the application is in stuck. So a breakpoint inside the try-with-resources statement is not reachable.
Does anybody have ideas what to do in such case?