[]
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());
voiddelete()voidIRange object for the cell range to which the formatting rule is applied.IBorders which represents the borders of this conditional format.getFont()IFont which represents the font of this conditional format.IInterior that represents the background color of this conditional format.true.booleanintintgetRank()booleantrue.TopBottom value that determines whether values are ranked from the top or bottom.getType()voidsetAppliesTo(IRange value) IRange object for the cell range to which the formatting rule is applied.void1 so that it will be evaluated before all other rules on the worksheet.voidvoidsetNumberFormat(String value) true.voidsetPercent(boolean value) voidsetPriority(int value) voidsetRank(int value) voidsetStopIfTrue(boolean value) true.voidsetTopBottom(TopBottom value) TopBottom value that determines whether values are ranked from the top or bottom.toJson()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();
IRange to which the formatting rule is applied.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"));
value - The range to which the formatting rule is applied.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);
IBorders object that represents the borders of this conditional format.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);
IFont object that represents the font of this conditional format.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());
IInterior object that represents the background color of this conditional format.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();
true.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");
value - The number format string applied when the conditional formatting rule evaluates to true.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();
true if the rank is determined by a percentage value; false if the rank is determined by a fixed count.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);
value - true if the rank is determined by a percentage value; false if the rank is determined by a fixed count.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();
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);
value - The priority value of the conditional formatting 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();
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);
value - The integer rank value for the conditional format rule.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();
true.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);
value - A Boolean value that indicates whether additional formatting rules on the cell should be evaluated if the current rule evaluates to true.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();
TopBottom value that indicates whether values are ranked from the top or bottom.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);
value - One of the TopBottom constants that specifies whether the conditional formatting rule evaluates the top-ranked values or the bottom-ranked values.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();
FormatConditionType of 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();
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();
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();
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());
json - The JSON string used to generate the conditional format. The format condition type in the JSON must match this ITop10 instance.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();