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

Getting cell content with DataFormatter is no longer working with Apache POI 4.1.0 because getSheet is unsupported #193

Closed borjapenman closed 5 years ago

borjapenman commented 5 years ago

As you can see at: https://poi.apache.org/components/spreadsheet/quick-guide.html#CellContents

The suggested way to get contents from a cell as a string is using the DataFormatter. In the latest version of POI (4.1.0) this relays on the unsupported getSheet() operation which is used in the private method isDate1904:

` private boolean isDate1904(Cell cell) { if ( cell != null && cell.getSheet().getWorkbook() instanceof Date1904Support) { return ((Date1904Support)cell.getSheet().getWorkbook()).isDate1904();

    }
    return false;
}`

Using a previous version of POI (4.0.1) is working, but I guess newer versions of POI will have the same behavior. Why is this method unsupported? I understand that you could use the Sheet to access random places, but those should be the unsupported methods, not getting the sheet and the workbook itself. Am I wrong?

Thanks in advance for your time

pjfanning commented 5 years ago

https://github.com/monitorjbl/excel-streaming-reader/commit/c7422985a45229eb73340ac703399fa48bad2ff3#diff-b85f73beeb9119231359e61e333922e0R273 getSheet is implemented in trunk

This is not released.

I have a fork with a release that supports POI 4.1. https://github.com/pjfanning/excel-streaming-reader/

borjapenman commented 5 years ago

Excellent! Thanks a lot