java - How can I force Apache POI to use cell formats when auto sizing columns? -
java - How can I force Apache POI to use cell formats when auto sizing columns? -
i using apache poi generate excel spreadsheets (.xlsx). many of cell styles contain info format strings, when columns containing such styles auto-resized column width based on unformatted cell contents.
example:
dataformat format = wb.createdataformat(); cellstyle dollars_m = wb.createcellstyle(); dollars_m.setdataformat(format.getformat("_($* #,##0.0,,\"m\"_);_($* (#,##0.0,,\"m\");_(@_)")); a cell value of 123456789.01 resize though cell contained 12 characters rather 8 ($ 123.5m) contain.
i able forcefulness formula's resolve before auto-resizing, there method forcefulness formats apply?
as of 3.10 apache poi applies formats before determining width of column in autosizecolumn. formula cells must evaluated using dataformatter#evaluateincell before autosizecolumn called otherwise width based on cached formula result.
java excel apache-poi
Comments
Post a Comment