> ## Documentation Index
> Fetch the complete documentation index at: https://docs.reducto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Conditional formats and validation

## `ConditionalFormatCollection`

`Excel.ConditionalFormatCollection`: the rules that touch a range, in priority order.

Import from `@reductoai/xlsx/officejs`.

### ConditionalFormatCollection properties

| Name | Type | Description |
| - | - | - |
| `count` | `number` | read-only |
| `items` | `ConditionalFormat[]` | read-only |

### `ConditionalFormatCollection.add()`

```ts theme={null}
add(type: ConditionalFormatType): ConditionalFormat
```

Adds a rule on the range at the top priority.

### `ConditionalFormatCollection.clearAll()`

```ts theme={null}
clearAll(): void
```

Removes every rule from the range's cells; rules that also cover other cells keep those.

### `ConditionalFormatCollection.getCount()`

```ts theme={null}
getCount(): ClientResult<number>
```

### `ConditionalFormatCollection.getItem()`

```ts theme={null}
getItem(id: string): ConditionalFormat
```

### `ConditionalFormatCollection.getItemAt()`

```ts theme={null}
getItemAt(index: number): ConditionalFormat
```

### `ConditionalFormatCollection.getItemOrNullObject()`

```ts theme={null}
getItemOrNullObject(id: string): ConditionalFormat
```

## `ConditionalFormat`

`Excel.ConditionalFormat`: one rule; a handle stays valid until the rule is deleted.

Import from `@reductoai/xlsx/officejs`.

### ConditionalFormat properties

| Name | Type | Description |
| - | - | - |
| `cellValue` | `CellValueConditionalFormat` | read-only |
| `cellValueOrNullObject` | `CellValueConditionalFormat` | read-only |
| `colorScale` | `ColorScaleConditionalFormat` | read-only |
| `colorScaleOrNullObject` | `ColorScaleConditionalFormat` | read-only |
| `custom` | `CustomConditionalFormat` | read-only |
| `customOrNullObject` | `CustomConditionalFormat` | read-only |
| `dataBar` | `DataBarConditionalFormat` | read-only |
| `dataBarOrNullObject` | `DataBarConditionalFormat` | read-only |
| `iconSet` | `IconSetConditionalFormat` | read-only |
| `iconSetOrNullObject` | `IconSetConditionalFormat` | read-only |
| `id` | `string` | read-only |
| `preset` | `PresetCriteriaConditionalFormat` | read-only |
| `presetOrNullObject` | `PresetCriteriaConditionalFormat` | read-only |
| `priority` | `number` | 0 is the rule Excel applies first. |
| `stopIfTrue` | `boolean` | |
| `textComparison` | `TextConditionalFormat` | read-only |
| `textComparisonOrNullObject` | `TextConditionalFormat` | read-only |
| `topBottom` | `TopBottomConditionalFormat` | read-only |
| `topBottomOrNullObject` | `TopBottomConditionalFormat` | read-only |
| `type` | `ConditionalFormatType` | read-only |

### `ConditionalFormat.changeRuleToCellValue()`

```ts theme={null}
changeRuleToCellValue(rule: ConditionalCellValueRule): void
```

### `ConditionalFormat.changeRuleToColorScale()`

```ts theme={null}
changeRuleToColorScale(): void
```

### `ConditionalFormat.changeRuleToContainsText()`

```ts theme={null}
changeRuleToContainsText(rule: ConditionalTextComparisonRule): void
```

### `ConditionalFormat.changeRuleToCustom()`

```ts theme={null}
changeRuleToCustom(formula: string): void
```

### `ConditionalFormat.changeRuleToDataBar()`

```ts theme={null}
changeRuleToDataBar(): void
```

### `ConditionalFormat.changeRuleToIconSet()`

```ts theme={null}
changeRuleToIconSet(): void
```

### `ConditionalFormat.changeRuleToPresetCriteria()`

```ts theme={null}
changeRuleToPresetCriteria(rule: ConditionalPresetCriteriaRule): void
```

### `ConditionalFormat.changeRuleToTopBottom()`

```ts theme={null}
changeRuleToTopBottom(rule: ConditionalTopBottomRule): void
```

### `ConditionalFormat.delete()`

```ts theme={null}
delete(): void
```

### `ConditionalFormat.duplicate()`

```ts theme={null}
duplicate(): ConditionalFormat
```

Extension: a copy of the rule right after it, as Manage Rules' Duplicate Rule makes.

### `ConditionalFormat.getRange()`

```ts theme={null}
getRange(): ExcelRange
```

The cells the rule covers; throws when they are not one rectangle.

### `ConditionalFormat.getRangeAddresses()`

```ts theme={null}
getRangeAddresses(): string[]
```

Extension: the addresses of every area the rule covers.

### `ConditionalFormat.getRangeOrNullObject()`

```ts theme={null}
getRangeOrNullObject(): ExcelRange
```

### `ConditionalFormat.getRanges()`

```ts theme={null}
getRanges(): RangeAreas
```

### `ConditionalFormat.set()`

```ts theme={null}
set(
  properties: ConditionalFormat | UpdateData<ConditionalFormat>,
  options?: UpdateOptions,
): void
```

Sets several properties at once; a navigation member takes a nested batch.

### `ConditionalFormat.setRanges()`

```ts theme={null}
setRanges(ranges: string | ExcelRange | RangeAreas): void
```

Moves the rule to other cells; formulas Excel writes for a typed rule follow the new top-left cell.

## `DataValidation`

`Excel.DataValidation`: the rules on the cells of a range or of several areas.

Import from `@reductoai/xlsx/officejs`.

### DataValidation properties

| Name | Type | Description |
| - | - | - |
| `errorAlert` | `DataValidationErrorAlert` | |
| `ignoreBlanks` | `boolean` | |
| `prompt` | `DataValidationPrompt` | |
| `rule` | `DataValidationRule` | |
| `spread` | `"none" \| "all" \| "some" \| "mixed"` | read-only Extension: no rule here, one rule over every cell, one over some cells, or several rules. |
| `type` | `DataValidationType` | read-only |
| `valid` | `boolean \| null` | read-only true when every cell passes, false when none does, null for a mix. |

### `DataValidation.clear()`

```ts theme={null}
clear(): void
```

### `DataValidation.getInvalidCells()`

```ts theme={null}
getInvalidCells(): RangeAreas
```

The cells whose values fail their rule; throws when every cell passes.

### `DataValidation.getInvalidCellsOrNullObject()`

```ts theme={null}
getInvalidCellsOrNullObject(): RangeAreas & { isNullObject: boolean }
```

### `DataValidation.set()`

```ts theme={null}
set(
  properties: DataValidation | UpdateData<DataValidation>,
  options?: UpdateOptions,
): void
```

Sets several properties at once; a navigation member takes a nested batch.
