https://issues.apache.org/bugzilla/show_bug.cgi?id=56377

--- Comment #7 from [email protected] ---
I have debugged and I found the following:

This is the stack trace after calling the autoSizeColumn method:

1. org.apache.poi.xssf.usermodel.XSSFSheet.autoSizeColumn(int, boolean): line
386 --> calls the getColumnWidth
2. org.apache.poi.ss.util.SheetUtil.getColumnWidth(Sheet, int, boolean): line
203 --> Creates a default DataFormatter and then gets the cell.
3. org.apache.poi.xssf.usermodel.XSSFRow.getCell(int, MissingCellPolicy): line
204 --> Gets a cell with the following string value 41816.59016799769

This value is generated here: 

3.1: when we set the date of the date like this.        
GMT_CALENDAR.setTime(new Date());
cell.setCellValue(GMT_CALENDAR);
3.2: org.apache.poi.xssf.usermodel.XSSFCell.setCellValue(Calendar): line 630
--> converts to numeric excel date
3.3: org.apache.poi.xssf.usermodel.XSSFCell.setCellValue(double): line 238 -->
gets the string value of this number

4. org.apache.poi.ss.util.SheetUtil.getCellWidth(Cell, int, DataFormatter,
boolean): line 156 --> For the CellType numeric gets the string value
41816.59016799769
5. org.apache.poi.ss.util.SheetUtil.getCellWidth(Cell, int, DataFormatter,
boolean): line 164 --> Add "0" to this value
6. org.apache.poi.ss.util.SheetUtil.getCellWidth(Cell, int, DataFormatter,
boolean): line 183 --> Calculates the width value:
(layout.getBounds().getWidth() / colspan) / defaultCharWidth) +
cell.getCellStyle().getIndention(). 
((96.7158203125 / 1)/5) + 0 = 19.34

If I put this numeric value (41816.590167997690) in excel and we make it fit
with the content and then I check the column width, I get this 19.34 value.
The expected width should be 22px, for the formatted data: '2014-06-26 14:41:12
GMT'.

So it's not using the same format I set to the date, It's using a numeric
default format for date and then gets the width for that.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to