https://issues.apache.org/bugzilla/show_bug.cgi?id=55105
Bug ID: 55105
Summary: autoSizeColumn not working properly for data type
values
Product: POI
Version: 3.9
Hardware: PC
Status: NEW
Severity: major
Priority: P2
Component: XSSF
Assignee: [email protected]
Reporter: [email protected]
Workbook wb = new XSSFWorkbook();
CreationHelper createHelper = wb.getCreationHelper();
Sheet sheet = wb.createSheet();
Row row = sheet.createRow(0);
CellStyle cellStyle = wb.createCellStyle();
cellStyle.setDataFormat((short) 14);
Cell cell = row.createCell(0);
cell.setCellType(Cell.CELL_TYPE_NUMERIC);
cell.setCellValue(new Date("13-jan-2013"));
cell.setCellStyle(cellStyle);
cell = row.createCell(1);
cell.setCellType(Cell.CELL_TYPE_STRING);
cell.setCellValue("13-jan-2013");
cell.setCellStyle(cellStyle);
sheet.autoSizeColumn(0, false);
sheet.autoSizeColumn(1, false);
In the above example I am adding 2 cells to different columns. One has string
type value and other has date type value. Value is same "13-jan-2013"
When I call autosizecolumn in both columns, first ccolumn doesnt exapnd to fit
in the data whereas 2nd column expands properly.
I noticed this thing :
Internally autosizecolumn is using SheetUtil.getColumnWidth to get current max
width of column. It is returning a value of 8 something.
Previously autosizecolumn was using ColumnHelper.getColumnWidth method and
used to return 12 for same data ("13-jan-2013"). This is why in previous
version autosizecolumn was working properly for even date type fields
--
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]