2

I'm trying to use PrimeFaces DataExporter to export an xlsxstream type of file, but I seem to be getting this error:

WARNING: Could not auto-size column. Make sure the column was tracked prior to auto-sizing the column.
java.lang.IllegalStateException: Could not auto-size column. Make sure the column was tracked prior to auto-sizing the column.
    at org.apache.poi.xssf.streaming.SXSSFSheet.autoSizeColumn(SXSSFSheet.java:1606)
    at org.apache.poi.xssf.streaming.SXSSFSheet.autoSizeColumn(SXSSFSheet.java:1560)
    at org.primefaces.component.export.ExcelExporter.export(ExcelExporter.java:85)
    at org.primefaces.component.export.DataExporter.processAction(DataExporter.java:145)
    at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
    ...

Any idea how to debug this, or what the cause might be?

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Andrei Statescu
  • 329
  • 1
  • 6
  • 22
  • 1
    This feels like a bug in the PF implementation of XLSX. I would report it on the GitHub issues page with your sample XHTML snippet and this exception. – Melloware Aug 22 '18 at 16:43
  • No, no 'snippets'... a full [mcve].... and version info – Kukeltje Aug 22 '18 at 17:07
  • Looks like it can be fixed: https://stackoverflow.com/questions/14497082/autosizecolumns-on-sxssfworkbook/14497475 . But I think that will have to be fixed in the PF code. However you can try making sure none of your col/row values are NULL instead make them empty string "". – Melloware Aug 22 '18 at 23:38
  • Seems like replacing 'xlsxstream' with 'xslx' provided a quick fix for me here – Andrei Statescu Sep 05 '18 at 12:13
  • That is a quick fix but your app will now use way more memory generating your XLSX as long as you are OK with that. I think I am going to report and fix this bug in Primefaces. – Melloware Sep 11 '18 at 12:51

1 Answers1

2

Bug reported to PrimeFaces: https://github.com/primefaces/primefaces/issues/4034

I fixed it for PF 6.3: https://github.com/primefaces/primefaces/pull/4035

Melloware
  • 10,435
  • 2
  • 32
  • 62