0
votes

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);
1
Which version of xlsx-streamer are you using?Rcordoval
which version of java are you using ?Arty
I have edited with the xlsx streamer versionSuhas
Java version 10.0.2Suhas
StreamingSheet.getRow is unsupported. Only iterating over the rows of a StreamingSheet is possible as shown in github.com/monitorjbl/excel-streaming-reader -> Usage.Axel Richter

1 Answers

0
votes

There is a bug about this error. Look Here.

You can change your java version to java 8 that can solve your problem.