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.
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.
Implemented in r1794084