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

Can't read file in multiple thread #79

Closed zequnyu closed 7 years ago

zequnyu commented 7 years ago

Hi, I just got a problem in the very basic line. I'm using JavaFx multi thread.

Workbook workbook = StreamingReader.builder().rowCacheSize(100).bufferSize(4096).open(is);

Every time it just crashes in this line. Tried to catch exception, but no exception displayed. Tried to print something as well, neither worked. Do you have any ideas what's going on? I really can't find anything wrong. Thank you so much.

monitorjbl commented 7 years ago

You mentioned multiple threads...this library is not threadsafe. The data is read from an XML file inside the XLSX document using a streaming XML parser. There's not a way to make that process threadsafe.

monitorjbl commented 7 years ago

I'm going to close this as multithreaded reads of a streaming XML parser are never going to be feasible. To work around your particular issue, you could just synchronize access to the Workbook/Sheet object. It won't really be multithreaded, but it will be threadsafe.