Bug 58461 - setDefaultColumnStyle() isn't applied to new cells without explicit style (only XSSF)
Summary: setDefaultColumnStyle() isn't applied to new cells without explicit style (on...
Status: RESOLVED DUPLICATE of bug 51037
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.13-dev
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-26 16:53 UTC by Raimund
Modified: 2015-09-30 12:11 UTC (History)
0 users



Attachments
Full test case; creates a file first per HSSF, then per XSSF to show the different Excel behaviour (2.09 KB, text/x-java)
2015-09-26 16:53 UTC, Raimund
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Raimund 2015-09-26 16:53:22 UTC
Created attachment 33149 [details]
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.
Comment 1 Dominik Stadler 2015-09-30 12:11:18 UTC
I'll close this as duplicate of bug 51037 and comment some information from this bug there to not loose it.

*** This bug has been marked as a duplicate of bug 51037 ***