[]
Represents the conditional formats associated with a range.
This collection provides access to the conditional formatting rules that apply to a range. Use it to inspect existing rules or add new rules such as cell value, expression, color scale, data bar, icon set, top 10, and above-average conditions.
public interface IFormatConditions
Public Interface IFormatConditions
IRange range = worksheet.Range["A1:A5"];
range.Value = new object[,] {{1}, {3}, {5}, {7}, {9}};
IFormatConditions formatConditions = range.FormatConditions;
formatConditions.Add(FormatConditionType.CellValue, FormatConditionOperator.Between, 1, 5);
| Name | Description |
|---|---|
| Count | Gets the number of objects in the collection. This collection contains the conditional formats associated with a range. |
| this[int] | Gets the conditional format at the specified zero-based index. Use this indexer to access an existing conditional format in the collection for a range. |
| Name | Description |
|---|---|
| Add(FormatConditionType, FormatConditionOperator, object, object) | Adds a new conditional format. Creates a conditional formatting rule of the specified type and adds it to this collection. |
| AddAboveAverage() | Returns a new IAboveAverage object representing a conditional formatting rule for the specified range. Use the returned object to configure an average-based conditional formatting rule, such as whether cells are evaluated as above or below the average. |
| AddColorScale(ColorScaleType) | Returns a new IColorScale object representing a conditional formatting rule that uses gradations in cell colors to indicate relative differences in the values of cells included in a selected range. Use |
| AddDatabar() | Returns an IDataBar object representing a data bar conditional formatting rule for the specified range. Use the returned rule to configure how data bars visualize relative cell values in the range, such as the bar fill type, color, direction, and whether cell values are displayed. |
| AddIconSetCondition() | Returns a new IIconSetCondition object which represents an icon setconditional formatting rule for the specified range. Use the returned rule to choose an icon set and configure the threshold criteria that determine which icon is displayed for each cell value. |
| AddTop10() | Returns an ITop10 object representing a conditional formatting rule for the specified range. Use the returned rule to configure whether the conditional formatting evaluates the top or bottom values in the range, and whether the rank is based on a count or a percentage. |
| AddUniqueValues() | Returns a new IUniqueValues object representing a conditional formatting rule for the specified range. The returned rule is added to this collection and is configured to evaluate unique values in the represented range. |
| Delete() | Deletes all conditional formats associated with the represented range. Use this method to remove every conditional formatting rule from the range's IFormatConditions collection. |
| FromJson(string) | Generates the conditional formats from the json string. This method clears the existing conditional formats in the current range first, and then applies new conditional formats from the specified JSON string. The conditional formats are created in the range on which this method is called. Range information contained in the JSON string is not preserved. |
| ToJson() | Generates a JSON string from the conditional formats. Use this method to serialize all conditional formatting rules associated with the range so that they can be stored or later restored with FromJson(string). |