AutosizeColumns on SXSSFWorkbook

Is it possible to auto-negotiate columns in an SXSSFWorkbook streaming? I implemented an export function to export a list of objects in excel. At first I used XSSFWorkbook (not streaming), and after all the cells were created, I authorized all the columns, the result was a good excel file.

For performance issues, we wanted to change the book to a streaming version, but this led to the creation of NullPointer in org.apache.poi.ss.util.SheetUtil.getCellWidth.

Is it possible to call autoSizeColumns for an SXSSFWorkbook?

Im using poi-ooxml 3.9, but I have the same problem in 3.8.

+15
source share
2 answers

You need to make sure that each cell matters.

We use the following code to set a string value in a cell:

Cell c = row.createCell(i); c.setCellValue(text == null ? "" : text ); 
+13
source

Use sheet.isColumnTrackedForAutoSizing (0); for the first and subsequent use for another column, I encountered an exception whenever the code autoSizeColumn (0) is executed. Using the code above, I solved the problem, and it would be nice to expand the width of the column based on the text.

0
source

All Articles