Spread.Services Documentation
Add Unique Rule
Spread.Services Documentation > Developer's Guide > Apply Conditional Formatting > Add Unique Rule

The unique rule in conditional formatting is applied to check whether the value entered in a cell is a unique value in that particular range. This is possible only when the duplication option is set to false. To check for the duplicate values, the duplicate rule is applied separately.

Unique rule can be added using the properties and methods of the IUniqueValues interface.

Refer to the following example code to add unique rule in a worksheet.

C#
Copy Code
// Adding Unique Rule
worksheet.Range["A1:A5"].Value = new object[,]
{
    {1},
    {2},
    {1},
    {3},
    {4}
};

IUniqueValues condition2 = worksheet.Range["A1:A5"].FormatConditions.AddUniqueValues();
condition2.DupeUnique = DupeUnique.Unique;
condition2.Font.Name = "Arial";