[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.IFormatCondition

IFormatCondition Interface

Represents a conditional format.

An IFormatCondition defines a conditional formatting rule for a worksheet range, including the rule type, the range to which the rule applies, and the formatting to use when the rule condition is met.

Namespace: GrapeCity.Documents.Excel
Assembly: DS.Documents.Excel.dll
Syntax
public interface IFormatCondition
Public Interface IFormatCondition
Examples
worksheet.Range["A1:B5"].Value = new object[,] {{1, 2}, {0, 1}, {0, 0}, {0, 3}, {4, 5}};
IFormatCondition condition = (IFormatCondition) worksheet.Range["B1:B5"]
    .FormatConditions.Add(FormatConditionType.Expression, FormatConditionOperator.None, "=A1", null);
condition.Interior.Color = Color.Yellow;
condition.Borders.Color = Color.Red;

Properties

Name Description
AppliesTo

Gets or sets the cell range to which the formatting rule is applied.

Borders

Gets an instance of IBorders that represents the borders of this conditional format.

Use the returned border collection to access or modify the border settings stored on the conditional formatting rule.

DateOperator

Gets or sets the TimePeriods date operator used in the format condition.

For a time period conditional formatting rule, this value indicates the relative date period used by the rule.

Font

Gets an instance of IFont that represents the font of this conditional format.

Use the returned font object to configure font settings that are applied when the conditional formatting rule is triggered.

Formula1

Gets or sets the first formula of this conditional format.

The property value represents the first comparison value or expression associated with the conditional formatting rule. Depending on the rule type, it can be a constant value, a string value, a cell reference, or a formula.

Formula2

Gets or sets the second formula of this conditional format.

This property is used by conditional formatting rules that store two formulas, such as CellValue rules that use the Between or NotBetween operator.

Interior

Gets an instance of IInterior which represents the background color of this conditional format.

Use the returned IInterior object to read or modify the fill settings applied when the conditional formatting rule is in effect.

NumberFormat

Gets or sets the number format applied to a cell if the conditional formatting rule evaluates to true.

This property returns the format string assigned to the conditional formatting rule.

Operator

Gets or sets the operator of this conditional format.

The operator specifies how the conditional formatting rule compares the cell value with the rule's formula values. For example, it can indicate comparisons such as equal, greater than, or between.

Priority

Gets or sets the priority value of the conditional formatting rule.

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.

StopIfTrue

Gets or 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 returns true, lower-priority formatting rules on the same cell are not evaluated after the current rule evaluates to true.

Text

Gets or sets a string value that specifies the text used by the conditional formatting rule.

Use this property to configure the text for a text-based conditional formatting rule. This value works together with TextOperator to define how the rule searches for matching text.

TextOperator

Returns one of the constants of the ContainsOperator enumeration,specifying the text search performed by the conditional formatting rule.

Use this property with a TextString conditional formatting rule to control whether the rule checks if cell text contains or does not contain the specified text, or begins or ends with it.

Type

Gets the type of this conditional format.

Methods

Name Description
Delete()

Deletes this conditional format.

Use this method to remove the current conditional formatting rule from the worksheet.

FromJson(string)

Generates the conditional format from the JSON string.

Use this method to restore a conditional formatting rule from a JSON string, such as one previously generated by ToJson().

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.

SetLastPriority()

Sets the evaluation order for this conditional formatting rule so it is evaluated after all other rules on the worksheet.

ToJson()

Generates a JSON string from the conditional format.

The returned string represents the current conditional formatting rule and can be used with FromJson(string) to recreate the rule.