Home » excel » java – Primefaces DataExporter – XLSX and XLSXSTREAM

java – Primefaces DataExporter – XLSX and XLSXSTREAM

Posted by: admin May 14, 2020 Leave a comment

Questions:

It seems that with the recent versions of PrimeFaces, new types were added for the DataExporter (see ExporterType from the current primefaces 6.2 docs)

I can’t seem to find anything on the web regarding the new Apache POI XLSX and XLSXSTREAM types. Can somebody explain the differences between the two of them? Is one more efficient that the other? Are there limitations regarding the size of the exported data?

How to&Answers:

I can explain. They both produce the exact same XLSX files which are the Open Document format of Excel files using Apache POI. There is no limit on size that I am aware of.

The big difference is how they get created.

XLSX – reads the whole document in memory

XLSXSTREAM – processes and garbage collects as it processes so its memory efficient.

From the POI Docs:

SXSSF (package: org.apache.poi.xssf.streaming) is an API-compatible
streaming extension of XSSF to be used when very large spreadsheets
have to be produced, and heap space is limited. SXSSF achieves its low
memory footprint by limiting access to the rows that are within a
sliding window.

Basically if you don’t care about your server resources use XLSX if you have many users downloading Excel files and JVM Memory is important to you use the XLSXSTREAM