[]
        
(Showing Draft Content)

ITop10

Interface ITop10


public interface ITop10
Represents a conditional formatting rule that highlights the top or bottom N values.

Use this interface to configure a top or bottom N ranking rule for a range. An ITop10 object is typically created by calling IFormatConditions.addTop10() on a range's conditional formatting collection, and then setting the rank, whether it is calculated as a percentage, and whether values are ranked from the top or bottom.


 worksheet.getRange("A1:A5").setValue(new Object[][] {{10}, {30}, {20}, {50}, {40}});
 ITop10 top10 = worksheet.getRange("A1:A5").getFormatConditions().addTop10();
 top10.setTopBottom(TopBottom.Top);
 top10.setRank(2);
 top10.getInterior().setColor(Color.GetRed());
 
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Deletes this conditional format.
    void
    Generates the conditional format from a JSON string.
    Returns the IRange object for the cell range to which the formatting rule is applied.
    Returns an instance of IBorders which represents the borders of this conditional format.
    Returns an instance of IFont which represents the font of this conditional format.
    Gets an instance of IInterior that represents the background color of this conditional format.
    Returns the number format applied to a cell if the conditional formatting rule evaluates to true.
    boolean
    Returns a Boolean value that indicates whether the rank is calculated as a percentage.
    int
    Returns the priority value of the conditional formatting rule.
    int
    Gets the rank value for the conditional format rule.
    boolean
    Returns a Boolean value that indicates whether additional formatting rules on the cell should be evaluated if the current rule evaluates to true.
    Returns a TopBottom value that determines whether values are ranked from the top or bottom.
    Returns the type of this conditional format.
    void
    Sets the IRange object for the cell range to which the formatting rule is applied.
    void
    Sets the priority value for this conditional formatting rule to 1 so that it will be evaluated before all other rules on the worksheet.
    void
    Sets the evaluation order for this conditional formatting rule so it is evaluated after all other rules on the worksheet.
    void
    Sets the number format applied to a cell if the conditional formatting rule evaluates to true.
    void
    setPercent(boolean value)
    Sets a Boolean value that indicates whether the rank is calculated as a percentage.
    void
    setPriority(int value)
    Sets the priority value of the conditional formatting rule.
    void
    setRank(int value)
    Sets the rank value for the conditional format rule.
    void
    setStopIfTrue(boolean value)
    Sets a Boolean value that indicates whether additional formatting rules on the cell should be evaluated if the current rule evaluates to true.
    void
    Sets a TopBottom value that determines whether values are ranked from the top or bottom.
    Generates a JSON string from the conditional format.
  • Method Details

    • getAppliesTo

      IRange getAppliesTo()
      Returns the IRange object for the cell range to which the formatting rule is applied.

      Use setAppliesTo(IRange) to change the range associated with this top 10 conditional formatting rule.

      
       worksheet.getRange("A1:A5").setValue(new Object[][] {{10}, {30}, {20}, {50}, {40}});
       ITop10 top10 = worksheet.getRange("A1:A5").getFormatConditions().addTop10();
       top10.getInterior().setColor(Color.GetYellow());
       top10.setRank(2);
       IRange appliesTo = top10.getAppliesTo();
       
      Returns:
      The IRange to which the formatting rule is applied.
    • setAppliesTo

      void setAppliesTo(IRange value)
      Sets the IRange object for the cell range to which the formatting rule is applied.

      Use this method to move an existing top 10 conditional formatting rule to a different range.

      
       worksheet.getRange("A1:A5").setValue(new Object[][] {{10}, {30}, {20}, {50}, {40}});
       ITop10 top10 = worksheet.getRange("A1:A5").getFormatConditions().addTop10();
       top10.getInterior().setColor(Color.GetYellow());
       top10.setRank(2);
       top10.setAppliesTo(worksheet.getRange("B1:B5"));
       
      Parameters:
      value - The range to which the formatting rule is applied.
    • getBorders

      IBorders getBorders()
      Returns an instance of IBorders which represents the borders of this conditional format.

      Use the returned IBorders object to configure the border formatting that is applied when the top 10 conditional formatting rule is triggered.

      
       worksheet.getRange("A1:A5").setValue(new Object[][] {{10}, {30}, {20}, {50}, {40}});
       ITop10 top10 = worksheet.getRange("A1:A5").getFormatConditions().addTop10();
       top10.getInterior().setColor(Color.GetYellow());
       top10.setRank(2);
       IBorders borders = top10.getBorders();
       borders.setLineStyle(BorderLineStyle.Thick);
       
      Returns:
      The IBorders object that represents the borders of this conditional format.
    • getFont

      IFont getFont()
      Returns an instance of IFont which represents the font of this conditional format.

      Use the returned IFont object to configure font settings that are applied when the top 10 conditional formatting rule is triggered.

      
       worksheet.getRange("A1:A5").setValue(new Object[][] {{10}, {30}, {20}, {50}, {40}});
       ITop10 top10 = worksheet.getRange("A1:A5").getFormatConditions().addTop10();
       top10.setRank(2);
       IFont font = top10.getFont();
       font.setBold(true);
       
      Returns:
      The IFont object that represents the font of this conditional format.
    • getInterior

      IInterior getInterior()
      Gets an instance of IInterior that represents the background color of this conditional format.

      Use the returned IInterior object to read or modify the fill settings applied when the top 10 conditional formatting rule evaluates to true.

      
       worksheet.getRange("A1:A5").setValue(new Object[][] {{10}, {30}, {20}, {50}, {40}});
       ITop10 top10 = worksheet.getRange("A1:A5").getFormatConditions().addTop10();
       top10.setRank(2);
       IInterior interior = top10.getInterior();
       interior.setColor(Color.GetRed());
       
      Returns:
      The IInterior object that represents the background color of this conditional format.
    • getNumberFormat

      String getNumberFormat()
      Returns the number format applied to a cell if the conditional formatting rule evaluates to true.

      The returned string uses an Excel-style number format pattern for this top or bottom N conditional formatting rule.

      
       worksheet.getRange("A1:A5").setValue(new Object[][] {{10}, {30}, {20}, {50}, {40}});
       ITop10 top10 = worksheet.getRange("A1:A5").getFormatConditions().addTop10();
       top10.getInterior().setColor(Color.GetYellow());
       top10.setRank(2);
       top10.setNumberFormat("0.00");
       String numberFormat = top10.getNumberFormat();
       
      Returns:
      The number format string applied when the conditional formatting rule evaluates to true.
    • setNumberFormat

      void setNumberFormat(String value)
      Sets the number format applied to a cell if the conditional formatting rule evaluates to true.

      The returned string uses an Excel-style number format pattern for this top or bottom N conditional formatting rule.

      
       worksheet.getRange("A1:A5").setValue(new Object[][] {{10}, {30}, {20}, {50}, {40}});
       ITop10 top10 = worksheet.getRange("A1:A5").getFormatConditions().addTop10();
       top10.getInterior().setColor(Color.GetYellow());
       top10.setRank(2);
       top10.setNumberFormat("0.00");
       
      Parameters:
      value - The number format string applied when the conditional formatting rule evaluates to true.
    • getPercent

      boolean getPercent()
      Returns a Boolean value that indicates whether the rank is calculated as a percentage.

      When this method returns true, the value specified by getRank() is interpreted as a percentage instead of a fixed count.

      
       worksheet.getRange("A1:A5").setValue(new Object[][] {{10}, {30}, {20}, {50}, {40}});
       ITop10 top10 = worksheet.getRange("A1:A5").getFormatConditions().addTop10();
       top10.getInterior().setColor(Color.GetYellow());
       top10.setRank(40);
       top10.setPercent(true);
       boolean isPercent = top10.getPercent();
       
      Returns:
      true if the rank is determined by a percentage value; false if the rank is determined by a fixed count.
    • setPercent

      void setPercent(boolean value)
      Sets a Boolean value that indicates whether the rank is calculated as a percentage.

      When this method sets true, the value specified by getRank() is interpreted as a percentage instead of a fixed count.

      
       worksheet.getRange("A1:A5").setValue(new Object[][] {{10}, {30}, {20}, {50}, {40}});
       ITop10 top10 = worksheet.getRange("A1:A5").getFormatConditions().addTop10();
       top10.getInterior().setColor(Color.GetYellow());
       top10.setRank(40);
       top10.setPercent(true);
       
      Parameters:
      value - true if the rank is determined by a percentage value; false if the rank is determined by a fixed count.
    • getPriority

      int getPriority()
      Returns the priority value of the conditional formatting rule. The priority determines the order of evaluation when multiple conditional formatting rules exist in a worksheet.

      The priority is a unique positive integer within the worksheet, so changing the priority of one rule can shift the priority values of other rules.

      
       worksheet.getRange("A1:B5").setValue(new Object[][] {{10, 5}, {30, 15}, {20, 25}, {50, 35}, {40, 45}});
       ITop10 firstRule = worksheet.getRange("A1:A5").getFormatConditions().addTop10();
       firstRule.getInterior().setColor(Color.GetYellow());
       ITop10 secondRule = worksheet.getRange("B1:B5").getFormatConditions().addTop10();
       secondRule.getInterior().setColor(Color.GetLightBlue());
       secondRule.setPriority(1);
       int priority = secondRule.getPriority();
       
      Returns:
      The priority value of the conditional formatting rule.
    • setPriority

      void setPriority(int value)
      Sets the priority value of the conditional formatting rule. The priority determines the order of evaluation when multiple conditional formatting rules exist in a worksheet.

      The priority is a unique positive integer within the worksheet, so changing the priority of one rule can shift the priority values of other rules.

      
       worksheet.getRange("A1:B5").setValue(new Object[][] {{10, 5}, {30, 15}, {20, 25}, {50, 35}, {40, 45}});
       ITop10 firstRule = worksheet.getRange("A1:A5").getFormatConditions().addTop10();
       firstRule.getInterior().setColor(Color.GetYellow());
       ITop10 secondRule = worksheet.getRange("B1:B5").getFormatConditions().addTop10();
       secondRule.getInterior().setColor(Color.GetLightBlue());
       secondRule.setPriority(1);
       
      Parameters:
      value - The priority value of the conditional formatting rule.
    • getRank

      int getRank()
      Gets the rank value for the conditional format rule.

      Returns an integer that specifies either the number of ranked items or the percentage value used by the rule, depending on getPercent().

      
       worksheet.getRange("A1:A5").setValue(new Object[][] {{10}, {30}, {20}, {50}, {40}});
       ITop10 top10 = worksheet.getRange("A1:A5").getFormatConditions().addTop10();
       top10.getInterior().setColor(Color.GetYellow());
       top10.setRank(2);
       int rank = top10.getRank();
       
      Returns:
      The integer rank value for the conditional format rule.
    • setRank

      void setRank(int value)
      Sets the rank value for the conditional format rule.

      Sets an integer that specifies either the number of ranked items or the percentage value used by the rule, depending on getPercent().

      
       worksheet.getRange("A1:A5").setValue(new Object[][] {{10}, {30}, {20}, {50}, {40}});
       ITop10 top10 = worksheet.getRange("A1:A5").getFormatConditions().addTop10();
       top10.getInterior().setColor(Color.GetYellow());
       top10.setRank(2);
       
      Parameters:
      value - The integer rank value for the conditional format rule.
    • getStopIfTrue

      boolean getStopIfTrue()
      Returns a Boolean value that indicates whether additional formatting rules on the cell should be evaluated if the current rule evaluates to true.
      
       worksheet.getRange("A1:A5").setValue(new Object[][] {{10}, {30}, {20}, {50}, {40}});
       ITop10 top10 = worksheet.getRange("A1:A5").getFormatConditions().addTop10();
       top10.getInterior().setColor(Color.GetYellow());
       top10.setStopIfTrue(true);
       boolean stopIfTrue = top10.getStopIfTrue();
       
      Returns:
      A Boolean value that indicates whether additional formatting rules on the cell should be evaluated if the current rule evaluates to true.
    • setStopIfTrue

      void setStopIfTrue(boolean value)
      Sets a Boolean value that indicates whether additional formatting rules on the cell should be evaluated if the current rule evaluates to true.
      
       worksheet.getRange("A1:A5").setValue(new Object[][] {{10}, {30}, {20}, {50}, {40}});
       ITop10 top10 = worksheet.getRange("A1:A5").getFormatConditions().addTop10();
       top10.getInterior().setColor(Color.GetYellow());
       top10.setStopIfTrue(true);
       
      Parameters:
      value - A Boolean value that indicates whether additional formatting rules on the cell should be evaluated if the current rule evaluates to true.
    • getTopBottom

      TopBottom getTopBottom()
      Returns a TopBottom value that determines whether values are ranked from the top or bottom.

      Use this method to inspect whether the conditional formatting rule evaluates the highest values or the lowest values in the applied range.

      
       worksheet.getRange("A1:A5").setValue(new Object[][] {{10}, {30}, {20}, {50}, {40}});
       ITop10 top10 = worksheet.getRange("A1:A5").getFormatConditions().addTop10();
       top10.getInterior().setColor(Color.GetYellow());
       top10.setTopBottom(TopBottom.Bottom);
       TopBottom topBottom = top10.getTopBottom();
       
      Returns:
      The TopBottom value that indicates whether values are ranked from the top or bottom.
    • setTopBottom

      void setTopBottom(TopBottom value)
      Sets a TopBottom value that determines whether values are ranked from the top or bottom.
      
       worksheet.getRange("A1:A5").setValue(new Object[][] {{10}, {30}, {20}, {50}, {40}});
       ITop10 top10 = worksheet.getRange("A1:A5").getFormatConditions().addTop10();
       top10.getInterior().setColor(Color.GetYellow());
       top10.setRank(2);
       top10.setTopBottom(TopBottom.Bottom);
       
      Parameters:
      value - One of the TopBottom constants that specifies whether the conditional formatting rule evaluates the top-ranked values or the bottom-ranked values.
    • getType

      Returns the type of this conditional format.

      Use this method to identify the conditional formatting rule type represented by this ITop10 instance. For a top or bottom N rule, the returned value is FormatConditionType.Top10.

      
       worksheet.getRange("A1:A5").setValue(new Object[][] {{10}, {30}, {20}, {50}, {40}});
       ITop10 top10 = worksheet.getRange("A1:A5").getFormatConditions().addTop10();
       top10.getInterior().setColor(Color.GetYellow());
       FormatConditionType type = top10.getType();
       
      Returns:
      The FormatConditionType of this conditional format.
    • delete

      void delete()
      Deletes this conditional format.

      Use this method to remove the current top or bottom conditional formatting rule from the worksheet.

      
       worksheet.getRange("A1:A5").setValue(new Object[][] {{10}, {30}, {20}, {50}, {40}});
       ITop10 top10 = worksheet.getRange("A1:A5").getFormatConditions().addTop10();
       top10.getInterior().setColor(Color.GetYellow());
       top10.setRank(2);
       top10.delete();
       
    • setFirstPriority

      void setFirstPriority()
      Sets the priority value for this conditional formatting rule to 1 so that it will be evaluated before all other rules on the worksheet.

      Calling this method is equivalent to setting the rule priority to 1. If other conditional formatting rules exist on the worksheet, their priority values may be adjusted accordingly.

      
       worksheet.getRange("A1:A5").setValue(new Object[][] {{10}, {30}, {20}, {50}, {40}});
       ITop10 firstRule = worksheet.getRange("A1:A5").getFormatConditions().addTop10();
       firstRule.getInterior().setColor(Color.GetYellow());
       ITop10 secondRule = worksheet.getRange("B1:B5").getFormatConditions().addTop10();
       secondRule.getInterior().setColor(Color.GetLightBlue());
       secondRule.setFirstPriority();
       
    • setLastPriority

      void setLastPriority()
      Sets the evaluation order for this conditional formatting rule so it is evaluated after all other rules on the worksheet.

      Use this method to move the current top 10 rule to the lowest evaluation priority among the conditional formatting rules in the worksheet.

      
       worksheet.getRange("A1:B5").setValue(new Object[][] {{10, 5}, {30, 15}, {20, 25}, {50, 35}, {40, 45}});
       ITop10 firstRule = worksheet.getRange("A1:A5").getFormatConditions().addTop10();
       firstRule.getInterior().setColor(Color.GetYellow());
       ITop10 secondRule = worksheet.getRange("B1:B5").getFormatConditions().addTop10();
       secondRule.getInterior().setColor(Color.GetLightBlue());
       secondRule.setLastPriority();
       
    • fromJson

      void fromJson(String json)
      Generates the conditional format from a JSON string.

      Use this method to update an existing top or bottom N conditional format from a JSON definition. The JSON must describe a top or bottom N conditional format for this ITop10 object. The caller's range is used to generate the conditional format, so the range information in the JSON is ignored.

      
       worksheet.getRange("A1:A5").setValue(new Object[][] {{10}, {30}, {20}, {50}, {40}});
       ITop10 top10 = worksheet.getRange("A1:A5").getFormatConditions().addTop10();
       top10.fromJson("{\"ruleType\":5,\"style\":{\"backColor\":\"Accent 5\"},\"type\":0,\"rank\":\"2\",\"ranges\":[{\"row\":0,\"rowCount\":5,\"col\":0,\"colCount\":1}]}");
       top10.getInterior().setColor(Color.GetYellow());
       
      Parameters:
      json - The JSON string used to generate the conditional format. The format condition type in the JSON must match this ITop10 instance.
    • toJson

      String toJson()
      Generates a JSON string from the conditional format.

      Use this method to serialize the current top or bottom N conditional formatting rule so that it can be stored or later restored with fromJson(String).

      
       worksheet.getRange("A1:A5").setValue(new Object[][] {
           {10}, {30}, {50}, {70}, {90}
       });
       ITop10 condition = worksheet.getRange("A1:A5").getFormatConditions().addTop10();
       condition.getInterior().setColor(Color.GetYellow());
       condition.setRank(3);
       String json = condition.toJson();
       
      Returns:
      The conditional format JSON string.