https://bz.apache.org/bugzilla/show_bug.cgi?id=58461
Bug ID: 58461
Summary: setDefaultColumnStyle() isn't applied to new cells
without explicit style (only XSSF)
Product: POI
Version: 3.13-dev
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P2
Component: XSSF
Assignee: [email protected]
Reporter: [email protected]
Created attachment 33149
--> https://bz.apache.org/bugzilla/attachment.cgi?id=33149&action=edit
Full test case; creates a file first per HSSF, then per XSSF to show the
different Excel behaviour
1. Applying default column style by Sheet.setDefaultColumnStyle
2. Adding new Cell; but don't set an explicit cell style
==> the default column style seems to be not applied if opening the file with
MS Excel 2010.
* Notes:
a) This works if using a HSSFWorkbook.
b) Strange: LibreOffice 4.3.7.2 displays the file as expected.
c) Maybe Bug 51037 deals with the same problem, but the description there is to
imprecise to reproduce it.
* Code snippet:
Workbook workbook = new XSSFWorkbook();
Sheet sheet = workbook.createSheet();
// Set default column style to user formatted time & yellow background
CellStyle style = workbook.createCellStyle();
style.setDataFormat(workbook.createDataFormat().getFormat("hh:mm:ss"));
style.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
sheet.setDefaultColumnStyle(0, style);
// Create one cell; cell contains actual date & time ...
Row row = sheet.createRow(0);
row.createCell(0).setCellValue(Calendar.getInstance());
* Results when viewing with MS Excel 2010:
The HSSF-file shows all cells - including the filled one - with yellow
background and formatted as time.
In the XSSF-file the filled cell has neither a background color nor a cell
format; the other cells of the column are formatted correctly.
Full test case appended; creates a file per HSSF & XSSF to show the differences
of Excel behaviour.
--
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]