[]
        
(Showing Draft Content)

IUniqueValues

Interface IUniqueValues


public interface IUniqueValues
Represents a conditional formatting rule that highlights duplicate or unique values in a range.

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);
 
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Deletes this conditional format.
    void
    Generates the conditional format from the specified JSON string.
    Returns an IRange object specifying the cell range to which the formatting rule is applied.
    Returns an instance of IBorders which represents the borders of this conditional format.
    Gets whether the conditional format rule is looking for unique or duplicate values.
    Returns an instance of IFont which represents the font of this conditional format.
    Returns an instance of IInterior which represents the background color of this conditional format.
    Gets the number format applied to a cell when the conditional formatting rule evaluates to true.
    int
    Returns the priority value of the conditional formatting rule.
    boolean
    Returns a Boolean value that determines if additional formatting rules on the cell should be evaluated if the current rule evaluates to True.
    Returns the type of this conditional format.
    void
    Sets an IRange object specifying the cell range to which the formatting rule is applied.
    void
    Sets whether the conditional format rule is looking for unique or duplicate values.
    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 when the conditional formatting rule evaluates to true.
    void
    setPriority(int value)
    Sets the priority value of the conditional formatting rule.
    void
    setStopIfTrue(boolean value)
    Sets a Boolean value that determines if additional formatting rules on the cell should be evaluated if the current rule evaluates to True.
    Generates a JSON string from the conditional format.
  • Method Details

    • getAppliesTo

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

      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();
       
      Returns:
      The range to which the formatting rule is applied.
    • setAppliesTo

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

      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"));
       
      Parameters:
      value - The IRange to which this formatting rule is applied. Must not be null.
    • getBorders

      IBorders getBorders()
      Returns an instance of 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);
       
      Returns:
      The IBorders object that represents the borders of this conditional format.
    • getDupeUnique

      DupeUnique getDupeUnique()
      Gets whether the conditional format rule is looking for unique or duplicate values.

      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();
       
      Returns:
      The DupeUnique value that indicates whether the conditional format rule looks for unique values or duplicate values.
    • setDupeUnique

      void setDupeUnique(DupeUnique value)
      Sets whether the conditional format rule is looking for unique 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);
       
      Parameters:
      value - The DupeUnique option that determines whether the rule matches unique or duplicate values. Must not be null.
    • getFont

      IFont getFont()
      Returns an instance of 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);
       
      Returns:
      The IFont object that represents the font of this conditional format.
    • getInterior

      IInterior getInterior()
      Returns an instance of 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());
       
      Returns:
      An IInterior object that represents the background color settings of this conditional format.
    • getNumberFormat

      String getNumberFormat()
      Gets the number format applied to a cell when the conditional formatting rule evaluates to 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();
       
      Returns:
      The number format applied when the conditional formatting rule evaluates to true.
    • setNumberFormat

      void setNumberFormat(String value)
      Sets the number format applied to a cell when the conditional formatting rule evaluates to 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");
       
      Parameters:
      value - The number format applied when the conditional formatting rule evaluates to true.
    • 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.

      
       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();
       
      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.

      
       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);
       
      Parameters:
      value - The priority value of the conditional formatting rule.
    • getStopIfTrue

      boolean getStopIfTrue()
      Returns a Boolean value that determines if additional formatting rules on the cell should be evaluated if the current rule evaluates to True.

      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();
       
      Returns:
      true if additional formatting rules are not evaluated when the current rule evaluates to true; otherwise, false.
    • setStopIfTrue

      void setStopIfTrue(boolean value)
      Sets a Boolean value that determines if additional formatting rules on the cell should be evaluated if the current rule evaluates to True.

      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);
       
      Parameters:
      value - true if additional formatting rules are not evaluated when the current rule evaluates to true; otherwise, false.
    • getType

      Returns the type of this conditional format.

      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();
       
      Returns:
      The type of this conditional format.
    • delete

      void delete()
      Deletes this conditional format.

      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();
       
    • 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: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();
       
    • 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 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();
       
    • fromJson

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

      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());
       
      Parameters:
      json - The JSON string that represents a unique-values or duplicate-values conditional format; null is not supported.
      Throws:
      IllegalStateException - if the JSON string does not represent a unique-values or duplicate-values conditional format.
    • toJson

      String toJson()
      Generates a JSON string from the 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();
       
      Returns:
      The conditional format JSON string.