monitorjbl / excel-streaming-reader

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

StreamingSheetReader$StreamingRowIterator requires hasNext() being called before next() #176

Open koch-rsi opened 5 years ago

koch-rsi commented 5 years ago

This will throw a NoSuchElementException, even if the sheet has 3 or more rows.

Workbook workbook = StreamingReader.builder()
    .rowCacheSize(2)
    .open(new ByteArrayInputStream(bytes));
Sheet sheet = workbook.getSheetAt(0);
Iterator<Row> rowIt = sheet.rowIterator();
rowIt.next();
rowIt.next();
rowIt.next();
jiaweim commented 5 years ago

Same problem when call next() Exception in thread "main" java.util.NoSuchElementException at java.util.ArrayList$Itr.next(ArrayList.java:862) at com.monitorjbl.xlsx.impl.StreamingSheetReader$StreamingRowIterator.next(StreamingSheetReader.java:407) at com.monitorjbl.xlsx.impl.StreamingSheetReader$StreamingRowIterator.next(StreamingSheetReader.java:393)

jhall38 commented 4 years ago

I also have come across this issue. For some reason when not calling hasNext, it will only read as many rows as what's set in rowCacheSize