monitorjbl / excel-streaming-reader

An easy-to-use implementation of a streaming Excel reader using Apache POI
Apache License 2.0
953 stars 344 forks source link

error during read file java.lang.IndexOutOfBoundsException #91

Closed marekzzz closed 7 years ago

marekzzz commented 7 years ago

Detailed printstack:

java.lang.IndexOutOfBoundsException: Index: 4, Size: 4
    at java.util.ArrayList.rangeCheck(ArrayList.java:653)
    at java.util.ArrayList.get(ArrayList.java:429)
    at com.monitorjbl.xlsx.impl.StreamingWorkbookReader.loadSheets(StreamingWorkbookReader.java:146)
    at com.monitorjbl.xlsx.impl.StreamingWorkbookReader.init(StreamingWorkbookReader.java:129)
    at com.monitorjbl.xlsx.impl.StreamingWorkbookReader.init(StreamingWorkbookReader.java:88)
    at com.monitorjbl.xlsx.StreamingReader$Builder.open(StreamingReader.java:263)

I use version 1.1.0

<groupId>com.monitorjbl</groupId>
<artifactId>xlsx-streamer</artifactId>

Additional info: File contines 4 sheet-s.

monitorjbl commented 7 years ago

Yeah, I just ran into this as well. Most of the unit tests were still using the old API, so this particular bit of code was not tested as thoroughly. I was in the process of converting them over as the old API is going to be removed in the near future and I hit this.

Not sure what triggers it yet, at first glance it appears that some workbooks have two sets of sheet properties for the same sheet.

monitorjbl commented 7 years ago

There's a fix in the latest code if you'd like to try it out. I still have no idea why some sheets have two sets of sheet refs for the same sheet though. The problem stems from this call, in almost every case that iterator contains the same number of values as there are sheets. But for a couple of test cases, it has a duplicate value.

marekzzz commented 7 years ago

Additionally

It occurs when a ran code:

InputStream is = new FileInputStream(new File(path));
Workbook workbook = StreamingReader.builder()
                .rowCacheSize(100)
                .bufferSize(4096).open(is);

I can test latest code. Could You give me a maven dependency to some snapshot jar.

Regards Marek

marekzzz commented 7 years ago

Hello, when might the version with the bug fix will be released?

monitorjbl commented 7 years ago

It's going to be a couple of weeks. In the meantime you can install the code locally to see if this fixes your issue.

marthursson commented 7 years ago

The bug fix appears to be working (verified against latest code in repo). Any new info on when the 1.2 version might be released?

monitorjbl commented 7 years ago

Just released to Maven Central now. Should be available in the next few hours!