Discussion:
Generating large spreadsheets and streaming responses
John D. Ament
2018-03-21 17:54:58 UTC
Permalink
Hi

I was wondering, are there any solutions in POI for streaming large
spreadsheets over an HTTP response? I have a JAX-RS backend that I
currently seed with POI. I use StreamingOutput to stream the worksheet to
the client. The problem is that this approach requires the entire
spreadsheet to be created in memory first and then sent over the wire. I'd
like to be able to send it out in a stream for performance reasons, as well
as getting the HTTP response sent out quicker.

John
Dominik Stadler
2018-03-21 20:25:37 UTC
Permalink
Not directly because the XML/ZIP format is not designed to support
streaming writing.

But there is SXSSFWorkbook which will write the content to a temporary file
while rows/cells are added and this way can build a potentially large .xlsx
file on disk without requiring a huge amount of memory. You can then stream
the resulting file as normal streaming copy from file to HTTP response,
also not requiring too much memory.

Dominik.
Post by John D. Ament
Hi
I was wondering, are there any solutions in POI for streaming large
spreadsheets over an HTTP response? I have a JAX-RS backend that I
currently seed with POI. I use StreamingOutput to stream the worksheet to
the client. The problem is that this approach requires the entire
spreadsheet to be created in memory first and then sent over the wire. I'd
like to be able to send it out in a stream for performance reasons, as well
as getting the HTTP response sent out quicker.
John
Loading...