Bug 51591 - org.apache.poi.ss.util.SheetUtil.getColumnWidth(sheet,col,false) does not apply full HSSFCellStyle
Summary: org.apache.poi.ss.util.SheetUtil.getColumnWidth(sheet,col,false) does not app...
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2011-07-30 21:46 UTC by Peter Costello
Modified: 2011-07-30 21:48 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Peter Costello 2011-07-30 21:46:00 UTC
Bug in org.apache.poi.ss.util.SheetUtil.getColumnWidth() (or in code that creates/manipulates HSSFCellStyle).

Define HSSFCellStyle using an underscore, such as "_ \"C$\"* #,##0_);[Red]_ \"C$\"* (#,##0);".  Add HSSFCell using this style and set value to a number, eg "123456789".  Trap at line 173 in SheetUtil.java. Formatted text will be "C$123,456,7890", where the trailing '0' is used to provide the spacing for negative values.  The formatted text needs a leading space as specified by the format string. Net result is that the width returned by the function is slightly too small and when a written file is opened in Excel, the column will display "#########" because the column is too narrow.