Author: nick
Date: Tue Feb 14 17:49:13 2017
New Revision: 1782995

URL: http://svn.apache.org/viewvc?rev=1782995&view=rev
Log:
Expose Priority from newer-style HSSF CF rules

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/record/CFRule12Record.java
    
poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFConditionalFormattingRule.java
    
poi/trunk/src/java/org/apache/poi/ss/usermodel/ConditionalFormattingRule.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/CFRule12Record.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/CFRule12Record.java?rev=1782995&r1=1782994&r2=1782995&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/CFRule12Record.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/CFRule12Record.java Tue Feb 
14 17:49:13 2017
@@ -331,6 +331,13 @@ public final class CFRule12Record extend
         formula_scale = Formula.create(ptgs);
     }
 
+    public int getPriority() {
+        return priority;
+    }
+    public void setPriority(int priority) {
+        this.priority = priority;
+    }
+
     public short getSid() {
         return sid;
     }

Modified: 
poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFConditionalFormattingRule.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFConditionalFormattingRule.java?rev=1782995&r1=1782994&r2=1782995&view=diff
==============================================================================
--- 
poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFConditionalFormattingRule.java
 (original)
+++ 
poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFConditionalFormattingRule.java
 Tue Feb 14 17:49:13 2017
@@ -60,11 +60,15 @@ public final class HSSFConditionalFormat
     }
 
     /**
-     * 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();
     }
     
     /**

Modified: 
poi/trunk/src/java/org/apache/poi/ss/usermodel/ConditionalFormattingRule.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/ConditionalFormattingRule.java?rev=1782995&r1=1782994&r2=1782995&view=diff
==============================================================================
--- 
poi/trunk/src/java/org/apache/poi/ss/usermodel/ConditionalFormattingRule.java 
(original)
+++ 
poi/trunk/src/java/org/apache/poi/ss/usermodel/ConditionalFormattingRule.java 
Tue Feb 14 17:49:13 2017
@@ -147,10 +147,13 @@ public interface ConditionalFormattingRu
     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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to