Bug 61060 - DataFormatter should honor conditional formatting rule formats
Summary: DataFormatter should honor conditional formatting rule formats
Alias: None
Product: POI
Classification: Unclassified
Component: SS Common (show other bugs)
Version: 3.17-dev
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2017-05-02 00:48 UTC by Greg Woolsey
Modified: 2017-05-05 17:46 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Greg Woolsey 2017-05-02 00:48:46 UTC
Now that POI 3.16 supports evaluation of conditional formatting rules, DataFormatter should be extended to support formatting a cell based not only on it's style format, but the style format of the conditional formatting rule that applies, if there is one.

That is, prefer a conditional format rule cell format string over a cell style format string.

I think for compatibility and transparency this should be a distinct set of API calls, new methods on DataFormatter that take a ConditionalFormattingEvaluator and FormulaEvaluator, in addition to the current methods that take a FormulaEvaluator.

JavaDoc will note the two should be based on the same evaluation context for consistency and cache performance.

DataFormatter will need some refactoring to abstract out retrieving the applicable format objects, to centralize logic about which one applies in what cases.
Comment 1 Greg Woolsey 2017-05-03 23:07:11 UTC
Worth noting this is easy to find for XSSFConditionalFormattingRule, via the DXF entry's NumFmt element, however I do not see any way to find the number format pattern for HSSF conditional rules, even though when I save a file as XLS in Excel, and open it, the rule number formats are still there.

For now, HSSF rules will return null for the number format, the same as XSSF will when the dxf element doesn't have a NumFmt element set.  For these, the cell style number format (and possibly a system/document default) will be used as it is currently.

If anyone needs this for HSSF, they will have to dig into the binary format to figure out where to find it.  The SS interface will have a placeholder implementation for it.
Comment 2 Greg Woolsey 2017-05-05 17:46:06 UTC
Implemented in r1794084