AutosizeColumns on SXSSFWorkbook

前端 未结 3 864
渐次进展
渐次进展 2021-01-07 19:09

Is it possible to autoSizeColumns on a streaming SXSSFWorkbook? I implemented an export functionality to export a list of objects to excel. At first I used the XSSFWorkbook

相关标签:
3条回答
  • 2021-01-07 19:52

    Error: NullPointerException on org.apache.poi.ss.util.SheetUtil.getCellWidth(SheetUtil.java:122)

    Fix: Always set value to Cell as shown below, it throws NullPointerException when there is null in Cell, so set the value as:

    Cell c = row.createCell(i);
    c.setCellValue(text == null ? "" : text );
    
    0 讨论(0)
  • 2021-01-07 19:55

    You need to make sure every cell has a value.

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

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

    ** Cell should never be null values else it throws NullPointerException. Hence set the value as shown above.

    Thanks a lot, this helped!!

    0 讨论(0)
  • 2021-01-07 20:03

    Use sheet.isColumnTrackedForAutoSizing(0); for first and subsequently used for other column, i have faced exception whenever code executed autoSizeColumn(0) get executed. by using above code i have resolved the issue and it's good to expand the column width too based on the text.

    0 讨论(0)
提交回复
热议问题