Bug 60866 - [PATCH] Support for named cell styles in SS Common
Summary: [PATCH] Support for named cell styles in SS Common
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: SS Common (show other bugs)
Version: 3.16-dev
Hardware: PC Linux
: P2 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
Keywords: PatchAvailable
Depends on:
Reported: 2017-03-14 16:19 UTC by Martin Studer
Modified: 2017-03-19 07:53 UTC (History)
1 user (show)

Patch adding support for named cell styles (21.33 KB, patch)
2017-03-14 16:19 UTC, Martin Studer
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Studer 2017-03-14 16:19:14 UTC
Created attachment 34826 [details]
Patch adding support for named cell styles

Dear all,

I was working on support for named cell styles in SS Common. Please find attached a patch with the proposed changes. Would be great if someone could review that.

While HSSFCellStyle allowed setting a user style name for a while, this was not possible with XSSFCellStyle. Generally, the model in XSSF is a bit more complicated due to the separation of cell and cell style formatting records (cell xfs vs cell style xfs). An XSSFCellStyle in POI is generally a combination of both a cell xf and a cell style xf. Only the latter (actually only cell styles (CTCellStyle) which reference a cell style xf) can have a name. The idea of supporting named cell styles in XSSFCellStyle is therefore the following:

- an XSSFCellStyle which references an "empty" cell xf (i.e. no cell-specific formatting) which in turn references a cell style xf which has a name through a cell style record (CTCellStyle) is considered a named XSSFCellStyle
- a named XSSFCellStyle can be created at any time from a (non-named) XSSFCellStyle by merging the cell xf and cell style xf information and creating a new cell style xf record and an appropriate CTCellStyle entry; the XSSFCellStyle can be updated by using the newly created cell style xf and an empty cell xf

A test case which illustrates the use is included in the attached patch.

Best regards,