XSSF uses the priority field for conditional formatting to maintain the priority order of the conditional formatting rules. Currently, there is no way to read the priority field (private in CTCfRule) so there is no way to look through the list of conditional formatting in priority order. This was solved in this interesting code snippet: https://github.com/vaadin/spreadsheet/blob/master/vaadin-spreadsheet/src/main/java/com/vaadin/addon/spreadsheet/ConditionalFormatter.java It would be better if there was a way to loop through the conditional formatting in order of priority.
Don't suppose you know any of Vaadin Spreadsheet folks? I've tried to reach out to them about merging their support in, but didn't get anywhere In terms of the bug... What would be good is if someone could create a small test xlsx file, with conditional formatting that has non-standard priorities. Then do a save-as as xls, so we can check that too. Upload both, along with the guts of a new junit test that checks the priority order fetching Since the existing behaviour is out there, we may not be able to change the current signature / behaviour as-is. However, once we work out where the priority is in xls files, we can look to add alternate getters in priority order too, eg ConditionalFormattingRule getRule(int idx); // existing ConditionalFormattingRule getRuleByPriority(int priority); // new List<ConditionalFormattingRule> getRules(); // missing... List<ConditionalFormattingRule> getRulesByPriority(); // new, same idea Would that work for your use case?
Marking this as resolved with the addition of ConditionalFormattingEvaluator and EvaluationConditionalFormattingRule in 3.16. The evaluation rule class exposes the rule priority, and the evaluator class handles rules in priority order.