I want to read more than 600k rows from an excel (.xlsx) file.
I'm using Apache POI and xlsx-streamer.
<dependency>
<groupId>com.monitorjbl</groupId>
<artifactId>xlsx-streamer</artifactId>
<version>1.2.0</version>
</dependency>
Apache poi version is 3.15 because xlsx-streamer didn't support in above versions
I want to iterate only particular columns. What I have tried is:
File myFile = new File("testFile.xlsx");
FileInputStream fis = new FileInputStream(myFile);
Workbook workbook = StreamingReader.builder().bufferSize(4096).open(fis);
// Sheet sheet = workbook.getSheetAt(0);
for (Sheet sheet : workbook) {
for (int r = 0; r < sheet.getLastRowNum(); r++) {
Row rr = sheet.getRow(r);
for (int c = 1; c < rr.getLastCellNum(); c++) {
Cell cell = rr.getCell(c);
System.out.println("" + cell.getStringCellValue());
}
}
I get this exception with few warnings
Exception in thread "main" java.lang.UnsupportedOperationException
at com.monitorjbl.xlsx.impl.StreamingSheet.getRow(StreamingSheet.java:102)
at ReadExcel.main(ReadExcel.java:35)
Line #35 is
Row rr = sheet.getRow(r);
StreamingSheet
is possible as shown in github.com/monitorjbl/excel-streaming-reader -> Usage. – Axel Richter