# GC.Spread.Sheets.ConditionalFormatting.ConditionalFormats

## Content

# Class: ConditionalFormats

[Sheets](../modules/GC.Spread.Sheets).[ConditionalFormatting](../modules/GC.Spread.Sheets.ConditionalFormatting).ConditionalFormats

## Table of contents

### Constructors

- [constructor](GC.Spread.Sheets.ConditionalFormatting.ConditionalFormats#constructor)

### Methods

- [add2ScaleRule](GC.Spread.Sheets.ConditionalFormatting.ConditionalFormats#add2scalerule)
- [add3ScaleRule](GC.Spread.Sheets.ConditionalFormatting.ConditionalFormats#add3scalerule)
- [addAverageRule](GC.Spread.Sheets.ConditionalFormatting.ConditionalFormats#addaveragerule)
- [addCellValueRule](GC.Spread.Sheets.ConditionalFormatting.ConditionalFormats#addcellvaluerule)
- [addColumnStateRule](GC.Spread.Sheets.ConditionalFormatting.ConditionalFormats#addcolumnstaterule)
- [addDataBarRule](GC.Spread.Sheets.ConditionalFormatting.ConditionalFormats#adddatabarrule)
- [addDateOccurringRule](GC.Spread.Sheets.ConditionalFormatting.ConditionalFormats#adddateoccurringrule)
- [addDuplicateRule](GC.Spread.Sheets.ConditionalFormatting.ConditionalFormats#addduplicaterule)
- [addFormulaRule](GC.Spread.Sheets.ConditionalFormatting.ConditionalFormats#addformularule)
- [addIconSetRule](GC.Spread.Sheets.ConditionalFormatting.ConditionalFormats#addiconsetrule)
- [addRowStateRule](GC.Spread.Sheets.ConditionalFormatting.ConditionalFormats#addrowstaterule)
- [addRule](GC.Spread.Sheets.ConditionalFormatting.ConditionalFormats#addrule)
- [addSpecificTextRule](GC.Spread.Sheets.ConditionalFormatting.ConditionalFormats#addspecifictextrule)
- [addTop10Rule](GC.Spread.Sheets.ConditionalFormatting.ConditionalFormats#addtop10rule)
- [addUniqueRule](GC.Spread.Sheets.ConditionalFormatting.ConditionalFormats#adduniquerule)
- [clearRule](GC.Spread.Sheets.ConditionalFormatting.ConditionalFormats#clearrule)
- [containsRule](GC.Spread.Sheets.ConditionalFormatting.ConditionalFormats#containsrule)
- [count](GC.Spread.Sheets.ConditionalFormatting.ConditionalFormats#count)
- [getRule](GC.Spread.Sheets.ConditionalFormatting.ConditionalFormats#getrule)
- [getRules](GC.Spread.Sheets.ConditionalFormatting.ConditionalFormats#getrules)
- [removeRule](GC.Spread.Sheets.ConditionalFormatting.ConditionalFormats#removerule)
- [removeRuleByRange](GC.Spread.Sheets.ConditionalFormatting.ConditionalFormats#removerulebyrange)

## Constructors

### <a id="constructor" name="constructor"></a> constructor

• **new ConditionalFormats**(`worksheet`)

Represents a format condition class.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `worksheet` | [`Worksheet`](GC.Spread.Sheets.Worksheet) | The sheet. |

## Methods

### <a id="add2scalerule" name="add2scalerule"></a> add2ScaleRule

▸ **add2ScaleRule**(`minType`, `minValue`, `minColor`, `maxType`, `maxValue`, `maxColor`, `ranges`): [`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

Adds the two scale rule to the rule collection.

**`example`**
```javascript
//This example uses the add2ScaleRule method.
activeSheet.conditionalFormats.add2ScaleRule(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number,10,"Red",GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number,100,"Yellow", [new GC.Spread.Sheets.Range(0,0,10,3)]);
activeSheet.setValue(0,0, 1,3);
activeSheet.setValue(1,0, 50,3);
activeSheet.setValue(2,0, 100,3);
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `minType` | [`ScaleValueType`](../enums/GC.Spread.Sheets.ConditionalFormatting.ScaleValueType) | The minimum scale type. |
| `minValue` | `number` | The minimum scale value. |
| `minColor` | `string` | The minimum scale color. |
| `maxType` | [`ScaleValueType`](../enums/GC.Spread.Sheets.ConditionalFormatting.ScaleValueType) | The maximum scale type. |
| `maxValue` | `number` | The maximum scale value. |
| `maxColor` | `string` | The maximum scale color. |
| `ranges` | [`Range`](GC.Spread.Sheets.Range)[] | The cell ranges where the rule is applied whose item type is GC.Spread.Sheets.Range. |

#### Returns

[`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

The two scale rule added to the rule collection.

___

### <a id="add3scalerule" name="add3scalerule"></a> add3ScaleRule

▸ **add3ScaleRule**(`minType`, `minValue`, `minColor`, `midType`, `midValue`, `midColor`, `maxType`, `maxValue`, `maxColor`, `ranges`): [`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

Adds the three scale rule to the rule collection.

**`example`**
```javascript
//This example uses the add3ScaleRule method.
activeSheet.setValue(0,0, 1,3);
activeSheet.setValue(1,0, 50,3);
activeSheet.setValue(2,0, 100,3);
activeSheet.conditionalFormats.add3ScaleRule(1, 10, "red", 0, 50, "blue",2, 100, "yellow", [new GC.Spread.Sheets.Range(0, 0, 10, 3)]);
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `minType` | [`ScaleValueType`](../enums/GC.Spread.Sheets.ConditionalFormatting.ScaleValueType) | The minimum scale type. |
| `minValue` | `number` | The minimum scale value. |
| `minColor` | `string` | The minimum scale color. |
| `midType` | [`ScaleValueType`](../enums/GC.Spread.Sheets.ConditionalFormatting.ScaleValueType) | The midpoint scale type. |
| `midValue` | `number` | The midpoint scale value. |
| `midColor` | `string` | The midpoint scale color. |
| `maxType` | [`ScaleValueType`](../enums/GC.Spread.Sheets.ConditionalFormatting.ScaleValueType) | The maximum scale type. |
| `maxValue` | `number` | The maximum scale value. |
| `maxColor` | `string` | The maximum scale color. |
| `ranges` | [`Range`](GC.Spread.Sheets.Range)[] | The cell ranges where the rule is applied whose item type is GC.Spread.Sheets.Range. |

#### Returns

[`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

The three scale rule added to the rule collection.

___

### <a id="addaveragerule" name="addaveragerule"></a> addAverageRule

▸ **addAverageRule**(`type`, `style`, `ranges`): [`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

Adds an average rule to the rule collection.

**`example`**
```javascript
//This example uses the addAverageRule method.
activeSheet.setValue(0,0, 1,3);
activeSheet.setValue(1,0, 50,3);
activeSheet.setValue(2,0, 100,3);
activeSheet.setValue(3,0, 2,3);
activeSheet.setValue(4,0, 60,3);
activeSheet.setValue(5,0, 90,3);
activeSheet.setValue(6,0, 3,3);
activeSheet.setValue(7,0, 40,3);
activeSheet.setValue(8,0, 70,3);
activeSheet.setValue(9,0, 5,3);
activeSheet.setValue(10,0, 35,3);
var style = new GC.Spread.Sheets.Style();
style.backColor = "red";
style.borderLeft =new GC.Spread.Sheets.LineBorder("blue",GC.Spread.Sheets.LineStyle.medium);
style.borderTop = new GC.Spread.Sheets.LineBorder("blue",GC.Spread.Sheets.LineStyle.medium);
style.borderRight = new GC.Spread.Sheets.LineBorder("blue",GC.Spread.Sheets.LineStyle.medium);
style.borderBottom = new GC.Spread.Sheets.LineBorder("blue",GC.Spread.Sheets.LineStyle.medium);
activeSheet.conditionalFormats.addAverageRule(GC.Spread.Sheets.ConditionalFormatting.AverageConditionType.above,style,[new GC.Spread.Sheets.Range(0, 0, 10, 3)]);
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `type` | [`AverageConditionType`](../enums/GC.Spread.Sheets.ConditionalFormatting.AverageConditionType) | The average condition type. |
| `style` | [`Style`](GC.Spread.Sheets.Style) | The style that is applied to the cell when the condition is met. |
| `ranges` | [`Range`](GC.Spread.Sheets.Range)[] | The cell ranges where the rule is applied whose item type is GC.Spread.Sheets.Range. |

#### Returns

[`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

The average rule added to the rule collection.

___

### <a id="addcellvaluerule" name="addcellvaluerule"></a> addCellValueRule

▸ **addCellValueRule**(`comparisonOperator`, `value1`, `value2`, `style`, `ranges`): [`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

Adds the cell value rule to the rule collection.

**`example`**
```javascript
//This example uses the addCellValueRule method.
var style = new GC.Spread.Sheets.Style();
style.backColor = "red";
var ranges=[new GC.Spread.Sheets.Range(0,0,5,1)];
activeSheet.conditionalFormats.addCellValueRule(GC.Spread.Sheets.ConditionalFormatting.ComparisonOperators.between, 2, 100, style, ranges);
activeSheet.setValue(0,0,1,3);
activeSheet.setValue(1,0,45,3);
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `comparisonOperator` | [`ComparisonOperators`](../enums/GC.Spread.Sheets.ConditionalFormatting.ComparisonOperators) | The comparison operator. |
| `value1` | `Object` | The first value. |
| `value2` | `Object` | The second value. |
| `style` | [`Style`](GC.Spread.Sheets.Style) | The style that is applied to the cell when the condition is met. |
| `ranges` | [`Range`](GC.Spread.Sheets.Range)[] | The cell ranges where the rule is applied whose item type is GC.Spread.Sheets.Range. |

#### Returns

[`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

The cell value rule added to the rule collection.

___

### <a id="addcolumnstaterule" name="addcolumnstaterule"></a> addColumnStateRule

▸ **addColumnStateRule**(`state`, `style`, `ranges`): [`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

Adds a column state rule to the rule collection.

**`example`**
```javascript
// Add a hover state rule in column direction.
activeSheet.conditionalFormats.addColumnStateRule(GC.Spread.Sheets.RowColumnStates.hover, new GC.Spread.Sheets.Style("yellow"), [new GC.Spread.Sheets.Range(-1, -1, -1, -1)]);
activeSheet.conditionalFormats.addColumnStateRule(
     GC.Spread.Sheets.RowColumnStates.hover,
     [new GC.Spread.Sheets.Style("green"), new GC.Spread.Sheets.Style("red")],
     [new GC.Spread.Sheets.Range(1, 1, 10, 5), new GC.Spread.Sheets.Range(13, 1, 10, 5)]
);
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `state` | [`RowColumnStates`](../enums/GC.Spread.Sheets.RowColumnStates) | The state type. |
| `style` | [`Style`](GC.Spread.Sheets.Style) \| [`Style`](GC.Spread.Sheets.Style)[] | The row style if the columns are matched the state. It could be an array of styles. |
| `ranges` | [`Range`](GC.Spread.Sheets.Range)[] | The ranges where the rule is applied whose item type is GC.Spread.Sheets.Range. |

#### Returns

[`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

The state rule added to the rule collection.

___

### <a id="adddatabarrule" name="adddatabarrule"></a> addDataBarRule

▸ **addDataBarRule**(`minType`, `minValue`, `maxType`, `maxValue`, `color`, `ranges`): [`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

Adds a data bar rule to the rule collection.

**`example`**
```javascript
//This example uses the addDataBarRule method.
activeSheet.setValue(0,0,1,3);
activeSheet.setValue(1,0,15,3);
activeSheet.setValue(2,0,25,3);
activeSheet.setValue(3,0,-1,3);
activeSheet.conditionalFormats.addDataBarRule(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number, -1, GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number, 40, "orange", [new GC.Spread.Sheets.Range(0,0,4,1)]);
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `minType` | [`ScaleValueType`](../enums/GC.Spread.Sheets.ConditionalFormatting.ScaleValueType) | The minimum scale type. |
| `minValue` | `number` | The minimum scale value. |
| `maxType` | [`ScaleValueType`](../enums/GC.Spread.Sheets.ConditionalFormatting.ScaleValueType) | The maximum scale type. |
| `maxValue` | `number` | The maximum scale value. |
| `color` | `string` | The color data bar to show on the view. |
| `ranges` | [`Range`](GC.Spread.Sheets.Range)[] | The cell ranges where the rule is applied whose item type is GC.Spread.Sheets.Range. |

#### Returns

[`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

The data bar rule added to the rule collection.

___

### <a id="adddateoccurringrule" name="adddateoccurringrule"></a> addDateOccurringRule

▸ **addDateOccurringRule**(`type`, `style`, `ranges`): [`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

Adds the date occurring rule to the rule collection.

**`example`**
```javascript
//This example uses the addDateOccurringRule method.
var style = new GC.Spread.Sheets.Style();
style.backColor = "red";
var d = new Date();
activeSheet.setValue(0, 0, d);
activeSheet.setValue(1, 0, new Date(d.setDate(d.getDate()+1)));
activeSheet.setValue(2, 0, new Date(d.setDate(d.getDate()+5)));
activeSheet.setValue(3, 0,new Date(d.setDate(d.getDate()+6)));
activeSheet.setValue(4, 0,new Date(d.setDate(d.getDate()+7)));
activeSheet.setValue(5, 0, new Date(d.setDate(d.getDate()+8)));
activeSheet.conditionalFormats.addDateOccurringRule(GC.Spread.Sheets.ConditionalFormatting.DateOccurringType.nextWeek, style, [new GC.Spread.Sheets.Range(0,0,10,1)]);
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `type` | [`DateOccurringType`](../enums/GC.Spread.Sheets.ConditionalFormatting.DateOccurringType) | The data occurring type. |
| `style` | [`Style`](GC.Spread.Sheets.Style) | The style that is applied to the cell when the condition is met. |
| `ranges` | [`Range`](GC.Spread.Sheets.Range)[] | The cell ranges where the rule is applied whose item type is GC.Spread.Sheets.Range. |

#### Returns

[`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

The date occurring rule added to the rule collection.

___

### <a id="addduplicaterule" name="addduplicaterule"></a> addDuplicateRule

▸ **addDuplicateRule**(`style`, `ranges`): [`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

Adds a duplicate rule to the rule collection.

**`example`**
```javascript
//This example uses the addDuplicateRule method.
var style = new GC.Spread.Sheets.Style();
style.backColor = "yellow";
var ranges=[new GC.Spread.Sheets.Range(0,0,10,1)];
activeSheet.conditionalFormats.addDuplicateRule(style, ranges);
activeSheet.setValue(0, 0, 50);
activeSheet.setValue(1, 0, 50);
activeSheet.setValue(2, 0, 11);
activeSheet.setValue(3, 0, 5);
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `style` | [`Style`](GC.Spread.Sheets.Style) | The style that is applied to the cell when the condition is met. |
| `ranges` | [`Range`](GC.Spread.Sheets.Range)[] | The cell ranges where the rule is applied whose item type is GC.Spread.Sheets.Range. |

#### Returns

[`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

The duplicate rule added to the rule collection.

___

### <a id="addformularule" name="addformularule"></a> addFormulaRule

▸ **addFormulaRule**(`formula`, `style`, `ranges`): [`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

Adds the formula rule to the rule collection.

**`example`**
```javascript
//This example uses the addFormulaRule method.
var style = new GC.Spread.Sheets.Style();
style.backColor = "red";
var ranges = [new GC.Spread.Sheets.Range(0, 0, 2, 1)];
activeSheet.conditionalFormats.addFormulaRule("=A1=B1+C1", style, ranges);
activeSheet.setValue(0, 0, 2,3);
activeSheet.setValue(0, 1, 1,3);
activeSheet.setValue(0, 2,1,3);
activeSheet.setValue(1, 0, 1,3);
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `formula` | `string` | The condition formula. |
| `style` | [`Style`](GC.Spread.Sheets.Style) | The style that is applied to the cell when the condition is met. |
| `ranges` | [`Range`](GC.Spread.Sheets.Range)[] | The cell ranges where the rule is applied whose item type is GC.Spread.Sheets.Range. |

#### Returns

[`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

The formula rule added to the rule collection.

___

### <a id="addiconsetrule" name="addiconsetrule"></a> addIconSetRule

▸ **addIconSetRule**(`iconSetTye`, `ranges`): [`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

Adds an icon set rule to the rule collection.

**`example`**
```javascript
//This example uses the addIconSetRule method.
activeSheet.setValue(0,0,1,3);
activeSheet.setValue(1,0,15,3);
activeSheet.setValue(2,0,25,3);
activeSheet.setValue(3,0,-1,3);
activeSheet.conditionalFormats.addIconSetRule(GC.Spread.Sheets.ConditionalFormatting.IconSetType.fourTrafficLights, [new GC.Spread.Sheets.Range(0,0,4,1)]);
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `iconSetTye` | [`IconSetType`](../enums/GC.Spread.Sheets.ConditionalFormatting.IconSetType) | - |
| `ranges` | [`Range`](GC.Spread.Sheets.Range)[] | The cell ranges where the rule is applied whose item type is GC.Spread.Sheets.Range. |

#### Returns

[`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

The icon set rule added to the rule collection.

___

### <a id="addrowstaterule" name="addrowstaterule"></a> addRowStateRule

▸ **addRowStateRule**(`state`, `style`, `ranges`): [`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

Adds a row state rule to the rule collection.

**`example`**
```javascript
// Add a hover state rule in row direction.
activeSheet.conditionalFormats.addRowStateRule(GC.Spread.Sheets.RowColumnStates.hover, new GC.Spread.Sheets.Style("yellow"), [new GC.Spread.Sheets.Range(-1, -1, -1, -1)]);
// Add a hover state rule with variable styles
activeSheet.conditionalFormats.addRowStateRule(
     GC.Spread.Sheets.RowColumnStates.hover,
     [new GC.Spread.Sheets.Style("green"), new GC.Spread.Sheets.Style("red")],
     [new GC.Spread.Sheets.Range(1, 1, 10, 5), new GC.Spread.Sheets.Range(1, 7, 10, 5)]
);
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `state` | [`RowColumnStates`](../enums/GC.Spread.Sheets.RowColumnStates) | The state type. |
| `style` | [`Style`](GC.Spread.Sheets.Style) \| [`Style`](GC.Spread.Sheets.Style)[] | The row style if the rows are matched the state. It could be an array of styles. |
| `ranges` | [`Range`](GC.Spread.Sheets.Range)[] | The ranges where the rule is applied whose item type is GC.Spread.Sheets.Range. |

#### Returns

[`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

The state rule added to the rule collection.

___

### <a id="addrule" name="addrule"></a> addRule

▸ **addRule**(`rule`): [`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

Adds the rule.

**`example`**
```javascript
//This example uses the addRule method.
var scale = new GC.Spread.Sheets.ConditionalFormatting.ScaleRule();
scale.ruleType(GC.Spread.Sheets.ConditionalFormatting.RuleType.threeScaleRule);
scale.midColor("red");
scale.midType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
scale.midValue(50);
scale.maxColor("blue");
scale.maxType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
scale.maxValue(100);
scale.minColor("yellow");
scale.minType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
scale.minValue(10);
scale.ranges([new GC.Spread.Sheets.Range(0, 0, 10, 3)]);
activeSheet.conditionalFormats.addRule(scale);
activeSheet.setValue(0,0, 1,3);
activeSheet.setValue(1,0, 50,3);
activeSheet.setValue(2,0, 100,3);
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `rule` | [`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase) | The rule to add. |

#### Returns

[`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

___

### <a id="addspecifictextrule" name="addspecifictextrule"></a> addSpecificTextRule

▸ **addSpecificTextRule**(`comparisonOperator`, `text`, `style`, `ranges`): [`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

Adds the text rule to the rule collection.

**`example`**
```javascript
//This example uses the addSpecificTextRule method.
var style = new GC.Spread.Sheets.Style();
style.backColor = "red";
var ranges=[new GC.Spread.Sheets.Range(0,0,10,1)];
activeSheet.conditionalFormats.addSpecificTextRule(GC.Spread.Sheets.ConditionalFormatting.TextComparisonOperators.contains, "test", style, ranges);
activeSheet.setValue(0, 0, "testing");
activeSheet.setValue(1, 0, "test");
activeSheet.setValue(2, 0, "a");
activeSheet.setValue(3, 0, "t");
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `comparisonOperator` | [`TextComparisonOperators`](../enums/GC.Spread.Sheets.ConditionalFormatting.TextComparisonOperators) | The comparison operator. |
| `text` | `string` | The text for comparison. |
| `style` | [`Style`](GC.Spread.Sheets.Style) | The style that is applied to the cell when the condition is met. |
| `ranges` | [`Range`](GC.Spread.Sheets.Range)[] | The cell ranges where the rule is applied to items whose item type is GC.Spread.Sheets.Range. |

#### Returns

[`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

The text rule added to the rule collection.

___

### <a id="addtop10rule" name="addtop10rule"></a> addTop10Rule

▸ **addTop10Rule**(`type`, `rank`, `style`, `ranges`): [`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

Adds the top 10 rule or bottom 10 rule to the collection based on the Top10ConditionType object.

**`example`**
```javascript
//This example uses the addTop10Rule method.
var style = new GC.Spread.Sheets.Style();
style.backColor = "red";
var ranges=[new GC.Spread.Sheets.Range(0,0,10,1)];
activeSheet.conditionalFormats.addTop10Rule(GC.Spread.Sheets.ConditionalFormatting.Top10ConditionType.top, 2, style, ranges);
activeSheet.setValue(0, 0, 1);
activeSheet.setValue(1, 0, 50);
activeSheet.setValue(2, 0, 11);
activeSheet.setValue(3, 0, 5);
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `type` | [`Top10ConditionType`](../enums/GC.Spread.Sheets.ConditionalFormatting.Top10ConditionType) | The top 10 condition. |
| `rank` | `number` | The number of top or bottom items to apply the style to. |
| `style` | [`Style`](GC.Spread.Sheets.Style) | The style that is applied to the cell when the condition is met. |
| `ranges` | [`Range`](GC.Spread.Sheets.Range)[] | The cell ranges where the rule is applied whose item type is GC.Spread.Sheets.Range. |

#### Returns

[`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

The top 10 rule added to the rule collection.

___

### <a id="adduniquerule" name="adduniquerule"></a> addUniqueRule

▸ **addUniqueRule**(`style`, `ranges`): [`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

Adds a unique rule to the rule collection.

**`example`**
```javascript
//This example uses the addUniqueRule method.
var style = new GC.Spread.Sheets.Style();
style.backColor = "green";
activeSheet.setValue(0, 0, 50);
activeSheet.setValue(1, 0, 50);
activeSheet.setValue(2, 0, 11);
activeSheet.setValue(3, 0, 5);
activeSheet.conditionalFormats.addUniqueRule(style, [new GC.Spread.Sheets.Range(0,0,10,1)]);
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `style` | [`Style`](GC.Spread.Sheets.Style) | The style that is applied to the cell when the condition is met. |
| `ranges` | [`Range`](GC.Spread.Sheets.Range)[] | The cell ranges where the rule is applied whose item type is GC.Spread.Sheets.Range. |

#### Returns

[`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

The unique rule added to the rule collection.

___

### <a id="clearrule" name="clearrule"></a> clearRule

▸ **clearRule**(): `void`

Removes all rules.

**`example`**
```javascript
//This example uses the clearRule method.
activeSheet.setValue(0,0, 1,3);
activeSheet.setValue(1,0, 50,3);
activeSheet.setValue(2,0, 100,3);
activeSheet.conditionalFormats.add2ScaleRule(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number, 10, "red", GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number, 100, "yellow", [new GC.Spread.Sheets.Range(0, 0, 10, 3)]);
// Remove comment in front of method to test
//activeSheet.conditionalFormats.clearRule();
```

#### Returns

`void`

___

### <a id="containsrule" name="containsrule"></a> containsRule

▸ **containsRule**(`rule`, `row`, `column`): `boolean`

Determines whether the specified cell contains a specified rule.

**`example`**
```javascript
//This example checks to see if a cell has a specified rule.
var style = new GC.Spread.Sheets.Style();
style.backColor = "red";
var rule = new GC.Spread.Sheets.ConditionalFormatting.NormalConditionRule();
rule.ruleType(GC.Spread.Sheets.ConditionalFormatting.RuleType.cellValueRule);
rule.ranges([new GC.Spread.Sheets.Range(0,0,5,1)]);
rule.operator(GC.Spread.Sheets.ConditionalFormatting.ComparisonOperators.between);
rule.style(style);
rule.value1(2);
rule.value2(100);
activeSheet.conditionalFormats.addRule(rule);
activeSheet.setValue(0,0,1,3);
activeSheet.setValue(1,0,45,3);
var ruletest = activeSheet.conditionalFormats.containsRule(rule, 0, 0);
alert(ruletest);
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `rule` | [`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase) | The rule for which to check. |
| `row` | `number` | The row index. |
| `column` | `number` | The column index. |

#### Returns

`boolean`

`true` if the specified cell contains a specified rule; otherwise, `false`.

___

### <a id="count" name="count"></a> count

▸ **count**(): `number`

Gets the number of rule objects in the collection.

**`example`**
```javascript
//This example counts the rules.
var style = new GC.Spread.Sheets.Style();
style.backColor = "red";
var rule = new GC.Spread.Sheets.ConditionalFormatting.NormalConditionRule();
rule.ruleType(GC.Spread.Sheets.ConditionalFormatting.RuleType.cellValueRule);
rule.ranges([new GC.Spread.Sheets.Range(0,0,5,1)]);
rule.operator(GC.Spread.Sheets.ConditionalFormatting.ComparisonOperators.between);
rule.style(style);
rule.value1(2);
rule.value2(100);
activeSheet.conditionalFormats.addRule(rule);
activeSheet.setValue(0,0,1,3);
activeSheet.setValue(1,0,45,3);
var ruletest = activeSheet.conditionalFormats.count();
alert(ruletest);
```

#### Returns

`number`

The number of rule objects in the collection.

___

### <a id="getrule" name="getrule"></a> getRule

▸ **getRule**(`index`): [`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

Gets the rule using the index.

**`example`**
```javascript
//This example uses the getRule method.
var style = new GC.Spread.Sheets.Style();
style.backColor = "red";
var rule = new GC.Spread.Sheets.ConditionalFormatting.NormalConditionRule();
rule.ruleType(GC.Spread.Sheets.ConditionalFormatting.RuleType.cellValueRule);
rule.ranges([new GC.Spread.Sheets.Range(0,0,5,1)]);
rule.operator(GC.Spread.Sheets.ConditionalFormatting.ComparisonOperators.between);
rule.style(style);
rule.value1(2);
rule.value2(100);
activeSheet.conditionalFormats.addRule(rule);
activeSheet.setValue(0,0,1,3);
activeSheet.setValue(1,0,45,3);
var ruletest = activeSheet.conditionalFormats.getRule(0);
alert(ruletest.value1());
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `index` | `number` | The index from which to get the rule. |

#### Returns

[`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)

The rule from the index.

___

### <a id="getrules" name="getrules"></a> getRules

▸ **getRules**(`row`, `column`): [`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)[]

Gets the conditional rules from the cell at the specified row and column.

**`example`**
```javascript
//This example uses the getRules method.
var style = new GC.Spread.Sheets.Style();
style.backColor = "red";
var rule = new GC.Spread.Sheets.ConditionalFormatting.NormalConditionRule();
rule.ruleType(GC.Spread.Sheets.ConditionalFormatting.RuleType.cellValueRule);
rule.ranges([new GC.Spread.Sheets.Range(0,0,5,1)]);
rule.operator(GC.Spread.Sheets.ConditionalFormatting.ComparisonOperators.between);
rule.style(style);
rule.value1(2);
rule.value2(100);
activeSheet.conditionalFormats.addRule(rule);
activeSheet.setValue(0,0,1,3);
activeSheet.setValue(1,0,45,3);
var ruletest = activeSheet.conditionalFormats.getRules();
alert(ruletest[0].style().backColor);
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `row` | `number` | The row index. |
| `column` | `number` | The column index. |

#### Returns

[`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase)[]

The conditional rules.

___

### <a id="removerule" name="removerule"></a> removeRule

▸ **removeRule**(`rule`): `void`

Removes a rule object from the ConditionalFormats object.

**`example`**
```javascript
//This example uses the removeRule method.
var style = new GC.Spread.Sheets.Style();
style.backColor = "red";
var rule = new GC.Spread.Sheets.ConditionalFormatting.NormalConditionRule();
rule.ruleType(GC.Spread.Sheets.ConditionalFormatting.RuleType.cellValueRule);
rule.ranges([new GC.Spread.Sheets.Range(0,0,5,1)]);
rule.operator(GC.Spread.Sheets.ConditionalFormatting.ComparisonOperators.between);
rule.style(style);
rule.value1(2);
rule.value2(100);
activeSheet.conditionalFormats.addRule(rule);
activeSheet.setValue(0,0,1,3);
activeSheet.setValue(1,0,45,3);
activeSheet.conditionalFormats.removeRule(rule);
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `rule` | [`ConditionRuleBase`](GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase) | The rule object to remove from the ConditionalFormats object. |

#### Returns

`void`

___

### <a id="removerulebyrange" name="removerulebyrange"></a> removeRuleByRange

▸ **removeRuleByRange**(`row`, `column`, `rowCount`, `columnCount`): `void`

Removes the rules from a specified cell range.

**`example`**
```javascript
//This example uses the removeRuleByRange method.
var style = new GC.Spread.Sheets.Style();
style.backColor = "red";
var rule = new GC.Spread.Sheets.ConditionalFormatting.NormalConditionRule();
rule.ruleType(GC.Spread.Sheets.ConditionalFormatting.RuleType.cellValueRule);
rule.ranges([new GC.Spread.Sheets.Range(0,0,5,1)]);
rule.operator(GC.Spread.Sheets.ConditionalFormatting.ComparisonOperators.between);
rule.style(style);
rule.value1(2);
rule.value2(100);
activeSheet.conditionalFormats.addRule(rule);
activeSheet.setValue(0,0,1,3);
activeSheet.setValue(1,0,45,3);
activeSheet.conditionalFormats.removeRuleByRange(0, 0, 5, 1);
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `row` | `number` | The row index of the first cell in the range. |
| `column` | `number` | The column index of the first cell in the range. |
| `rowCount` | `number` | The number of rows in the range. |
| `columnCount` | `number` | The number of columns in the range. |

#### Returns

`void`
