Expose Priority from newer-style HSSF CF rules

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1782995 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2017-02-14 17:49:13 +00:00
parent c88649ccd2
commit 82244c3aae
3 changed files with 19 additions and 5 deletions

View File

@ -331,6 +331,13 @@ public final class CFRule12Record extends CFRuleBase implements FutureRecord, Cl
formula_scale = Formula.create(ptgs);
}
public int getPriority() {
return priority;
}
public void setPriority(int priority) {
this.priority = priority;
}
public short getSid() {
return sid;
}

View File

@ -60,11 +60,15 @@ public final class HSSFConditionalFormattingRule implements ConditionalFormattin
}
/**
* we don't know priority for these, other than definition/model order, which appears to be what Excel uses.
* Only newer style formatting rules have priorities. For older ones,
* we don't know priority for these, other than definition/model order,
* which appears to be what Excel uses.
* @see org.apache.poi.ss.usermodel.ConditionalFormattingRule#getPriority()
*/
public int getPriority() {
return 0;
CFRule12Record rule12 = getCFRule12Record(false);
if (rule12 == null) return 0;
return rule12.getPriority();
}
/**

View File

@ -147,10 +147,13 @@ public interface ConditionalFormattingRule {
String getFormula2();
/**
* HSSF just returns 0, XSSF uses the value stored in the model if present,
* otherwise uses 0.
* The priority of the rule, if defined, otherwise 0.
* <p/>
* If priority is 0, just use definition order, as that's how HSSF rules are evaluated.
* If priority is 0, just use definition order, as that's how older HSSF rules
* are evaluated.
* <p/>
* For XSSF, this should always be set. For HSSF, only newer style rules
* have this set, older ones will return 0.
* <p/>
* If a rule is created but not yet added to a sheet, this value may not be valid.
* @return rule priority