[]
Use getDupeUnique() and setDupeUnique(DupeUnique) to get or set a DupeUnique value that determines whether the rule should look for duplicate or unique values in the applied range. You can create this rule by using IFormatConditions.addUniqueValues() and then customize its formatting and target range.
worksheet.getRange("A1:A5").setValue(new Object[][] {
{100}, {100}, {200}, {300}, {300}
});
IUniqueValues condition = worksheet.getRange("A1:A5").getFormatConditions().addUniqueValues();
condition.getInterior().setColor(Color.GetYellow());
condition.setDupeUnique(DupeUnique.Unique);
voiddelete()voidIBorders which represents the borders of this conditional format.getFont()IFont which represents the font of this conditional format.IInterior which represents the background color of this conditional format.true.intbooleangetType()voidsetAppliesTo(IRange value) voidsetDupeUnique(DupeUnique value) void1 so that it will be evaluated before all other rules on the worksheet.voidvoidsetNumberFormat(String value) true.voidsetPriority(int value) voidsetStopIfTrue(boolean value) toJson()Use setAppliesTo(IRange) to change the range associated with this unique-values or duplicate-values conditional formatting rule.
worksheet.getRange("A1:A5").setValue(new Object[][] {
{100}, {100}, {200}, {300}, {300}
});
IUniqueValues condition = worksheet.getRange("A1:A5").getFormatConditions().addUniqueValues();
condition.getInterior().setColor(Color.GetYellow());
condition.setAppliesTo(worksheet.getRange("B1:B5"));
IRange appliesTo = condition.getAppliesTo();
Use this method to change the IRange associated with the current unique-values or duplicate-values conditional formatting rule.
worksheet.getRange("A1:A5").setValue(new Object[][] {
{100}, {100}, {200}, {300}, {300}
});
IUniqueValues condition = worksheet.getRange("A1:A5").getFormatConditions().addUniqueValues();
condition.getInterior().setColor(Color.GetYellow());
condition.setAppliesTo(worksheet.getRange("B1:B5"));
value - The IRange to which this formatting rule is applied. Must not be null.IBorders which represents the borders of this conditional format. Use the returned IBorders object to configure border formatting for cells that match this IUniqueValues rule.
worksheet.getRange("A1:A5").setValue(new Object[][] {
{100}, {100}, {200}, {300}, {400}
});
IUniqueValues condition = worksheet.getRange("A1:A5").getFormatConditions().addUniqueValues();
condition.getInterior().setColor(Color.GetYellow());
IBorders borders = condition.getBorders();
borders.setLineStyle(BorderLineStyle.DashDotDot);
IBorders object that represents the borders of this conditional format.Use this property to determine whether the IUniqueValues rule is configured to match duplicate values or unique values in the applied range.
worksheet.getRange("A1:A5").setValue(new Object[][] {
{100}, {100}, {200}, {300}, {300}
});
IUniqueValues condition = worksheet.getRange("A1:A5").getFormatConditions().addUniqueValues();
condition.getInterior().setColor(Color.GetYellow());
condition.setDupeUnique(DupeUnique.Unique);
DupeUnique dupeUnique = condition.getDupeUnique();
DupeUnique value that indicates whether the conditional format rule looks for unique values or duplicate values.Use this method to specify whether the rule matches DupeUnique.Unique values or DupeUnique.Duplicate values in the applied range.
worksheet.getRange("A1:A5").setValue(new Object[][] {
{100},
{100},
{200},
{300},
{300}
});
IUniqueValues condition = worksheet.getRange("A1:A5").getFormatConditions().addUniqueValues();
condition.getInterior().setColor(Color.GetYellow());
condition.setDupeUnique(DupeUnique.Duplicate);
value - The DupeUnique option that determines whether the rule matches unique or duplicate values. Must not be null.IFont which represents the font of this conditional format.Use the returned IFont object to configure the font that is applied when this unique-values or duplicate-values rule evaluates to true.
worksheet.getRange("A1:A5").setValue(new Object[][] {
{100}, {100}, {200}, {300}, {400}
});
IUniqueValues condition = worksheet.getRange("A1:A5").getFormatConditions().addUniqueValues();
IFont font = condition.getFont();
font.setBold(true);
IFont object that represents the font of this conditional format.IInterior which represents the background color of this conditional format. Use the returned object to configure the fill formatting that is applied when the unique-values or duplicate-values conditional formatting rule evaluates to true.
worksheet.getRange("A1:A5").setValue(new Object[][] {
{100}, {100}, {200}, {300}, {300}
});
IUniqueValues condition = worksheet.getRange("A1:A5").getFormatConditions().addUniqueValues();
IInterior interior = condition.getInterior();
interior.setColor(Color.GetYellow());
IInterior object that represents the background color settings of this conditional format.true. Use this method to retrieve the format code currently configured for a unique-values or duplicate-values conditional formatting rule.
worksheet.getRange("A1:A5").setValue(new Object[][] {
{100}, {100}, {200}, {300}, {300}
});
IUniqueValues condition = worksheet.getRange("A1:A5").getFormatConditions().addUniqueValues();
condition.getInterior().setColor(Color.GetYellow());
condition.setNumberFormat("0.00");
String numberFormat = condition.getNumberFormat();
true.true. Use this method to set the format code currently configured for a unique-values or duplicate-values conditional formatting rule.
worksheet.getRange("A1:A5").setValue(new Object[][] {
{100}, {100}, {200}, {300}, {300}
});
IUniqueValues condition = worksheet.getRange("A1:A5").getFormatConditions().addUniqueValues();
condition.getInterior().setColor(Color.GetYellow());
condition.setNumberFormat("0.00");
value - The number format applied when the conditional formatting rule evaluates to true.The priority determines the order of evaluation when multiple conditional formatting rules exist in a worksheet.
IUniqueValues firstRule = worksheet.getRange("A1:A5").getFormatConditions().addUniqueValues();
firstRule.getInterior().setColor(Color.GetYellow());
IUniqueValues secondRule = worksheet.getRange("B1:B5").getFormatConditions().addUniqueValues();
secondRule.getInterior().setColor(Color.GetLightBlue());
secondRule.setPriority(1);
int priority = secondRule.getPriority();
The priority determines the order of evaluation when multiple conditional formatting rules exist in a worksheet.
IUniqueValues firstRule = worksheet.getRange("A1:A5").getFormatConditions().addUniqueValues();
firstRule.getInterior().setColor(Color.GetYellow());
IUniqueValues secondRule = worksheet.getRange("B1:B5").getFormatConditions().addUniqueValues();
secondRule.getInterior().setColor(Color.GetLightBlue());
secondRule.setPriority(1);
value - The priority value of the conditional formatting rule.If this property is true, subsequent conditional formatting rules are not evaluated for cells where this unique-values or duplicate-values rule evaluates to true. If this property is false, later rules continue to be evaluated.
worksheet.getRange("A1:A5").setValue(new Object[][] {
{1}, {2}, {1}, {3}, {4}
});
IUniqueValues condition = worksheet.getRange("A1:A5").getFormatConditions().addUniqueValues();
condition.getInterior().setColor(Color.GetYellow());
condition.setDupeUnique(DupeUnique.Unique);
boolean stopIfTrue = condition.getStopIfTrue();
true if additional formatting rules are not evaluated when the current rule evaluates to true; otherwise, false.If this property is true, subsequent conditional formatting rules are not evaluated for cells where this unique-values or duplicate-values rule evaluates to true. If this property is false, later rules continue to be evaluated.
worksheet.getRange("A1:A5").setValue(new Object[][] {
{1}, {2}, {1}, {3}, {4}
});
IUniqueValues condition = worksheet.getRange("A1:A5").getFormatConditions().addUniqueValues();
condition.getInterior().setColor(Color.GetYellow());
condition.setDupeUnique(DupeUnique.Unique);
condition.setStopIfTrue(true);
value - true if additional formatting rules are not evaluated when the current rule evaluates to true; otherwise, false.Use this method to identify the conditional formatting rule type represented by this IUniqueValues instance. For a unique-values or duplicate-values rule, the returned value is FormatConditionType.UniqueValues.
worksheet.getRange("A1:A5").setValue(new Object[][] {
{1}, {2}, {1}, {3}, {4}
});
IUniqueValues condition = worksheet.getRange("A1:A5").getFormatConditions().addUniqueValues();
condition.getInterior().setColor(Color.GetYellow());
condition.setDupeUnique(DupeUnique.Unique);
FormatConditionType type = condition.getType();
Use this method to remove the current unique-values or duplicate-values conditional formatting rule from its worksheet.
worksheet.getRange("A1:A5").setValue(new Object[][] {
{100}, {100}, {200}, {300}, {300}
});
IUniqueValues condition = worksheet.getRange("A1:A5").getFormatConditions().addUniqueValues();
condition.getInterior().setColor(Color.GetYellow());
condition.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:B5").setValue(new Object[][] {
{1, 2}, {2, 2}, {1, 3}, {4, 3}, {5, 6}
});
IUniqueValues firstRule = worksheet.getRange("A1:A5").getFormatConditions().addUniqueValues();
firstRule.getInterior().setColor(Color.GetYellow());
IUniqueValues secondRule = worksheet.getRange("B1:B5").getFormatConditions().addUniqueValues();
secondRule.getInterior().setColor(Color.GetLightBlue());
secondRule.setFirstPriority();
Use this method to move the current unique-values or duplicate-values rule to the lowest evaluation priority among the conditional formatting rules in the worksheet.
worksheet.getRange("A1:B5").setValue(new Object[][] {
{1, 2}, {2, 2}, {1, 3}, {4, 3}, {5, 6}
});
IUniqueValues firstRule = worksheet.getRange("A1:A5").getFormatConditions().addUniqueValues();
firstRule.getInterior().setColor(Color.GetYellow());
IUniqueValues secondRule = worksheet.getRange("B1:B5").getFormatConditions().addUniqueValues();
secondRule.getInterior().setColor(Color.GetLightBlue());
secondRule.setLastPriority();
Use this method to restore the settings of a unique-values or duplicate-values conditional formatting rule from its JSON representation, such as a string returned by toJson().
worksheet.getRange("A1:A5").setValue(new Object[][] {
{100}, {100}, {200}, {300}, {300}
});
String json = "{\"ranges\":[{\"row\":0,\"col\":1,\"rowCount\":5,\"colCount\":1}],\"priority\":1,\"style\":{\"backColor\":\"rgb(255,255,0)\"},\"ruleType\":7}";
IUniqueValues targetRule = worksheet.getRange("B1:B5").getFormatConditions().addUniqueValues();
targetRule.fromJson(json);
targetRule.getInterior().setColor(Color.GetYellow());
json - The JSON string that represents a unique-values or duplicate-values conditional format; null is not supported.IllegalStateException - if the JSON string does not represent a unique-values or duplicate-values conditional format.Use this method to serialize the current unique-values or duplicate-values conditional formatting rule, including its settings and formatting, to a JSON string that can be reused with fromJson(String).
worksheet.getRange("A1:A5").setValue(new Object[][] {
{1}, {2}, {1}, {3}, {4}
});
IUniqueValues condition = worksheet.getRange("A1:A5").getFormatConditions().addUniqueValues();
condition.getInterior().setColor(Color.GetYellow());
condition.setDupeUnique(DupeUnique.Unique);
String json = condition.toJson();