# FConditionalFormattingBuilder

> Language fallback: requested `zh-CN`; content is `en-US`.

- Human documentation: [https://docs.univer.ai/zh-CN/reference/facade/conditional-formatting-builder](https://docs.univer.ai/zh-CN/reference/facade/conditional-formatting-builder)

- Agent Markdown: [https://docs.univer.ai/zh-CN/reference/facade/conditional-formatting-builder.md](https://docs.univer.ai/zh-CN/reference/facade/conditional-formatting-builder.md)

- Requested language: `zh-CN`

- Content language: `en-US`

- Documentation version: `1.0.0-rc.0`

- Source: [facade/conditional-formatting-builder.mdx](https://github.com/dream-num/documentation/blob/dev/content/reference/facade/conditional-formatting-builder.mdx)

---

## Access

Access through:

* [`FRange.createConditionalFormattingRule()`](https://docs.univer.ai/zh-CN/reference/facade/range.md#createconditionalformattingrule)
* [`FWorksheet.newConditionalFormattingRule()`](https://docs.univer.ai/zh-CN/reference/facade/worksheet.md#newconditionalformattingrule)

## Setup

Register [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) or a preset that includes it. In plugin mode, import `@univerjs/sheets-conditional-formatting/facade`. Additional methods below require their listed plugin packages. See [Facade setup](https://docs.univer.ai/zh-CN/guides/sheets/getting-started/facade.md).

## `@univerjs/sheets-conditional-formatting`

### `FConditionalFormattingBuilder.build`

Constructs a conditional format rule from the settings applied to the builder.

```typescript
build(): IConditionFormattingRule
```

**Returns**

The conditional format rule.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that highlights cells with values greater than 10 in red for the range A1:D10.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .whenNumberGreaterThan(10)
  .setBackground('#FF0000')
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`IConditionFormattingRule`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/models/type.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.getIconMap`

Get the icon set mapping dictionary.

```typescript
getIconMap(): Record<string, string[]>
```

**Returns**

The icon set mapping dictionary.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')
console.log(fWorksheet.newConditionalFormattingRule().getIconMap()) // icons key-value map
```

**Types:** [`Record`](https://unpkg.com/@typescript/typescript-darwin-arm64@7.0.2/lib/lib.es5.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.setAverage`

Set average rule.

```typescript
setAverage(operator: IAverageHighlightCell['operator']): ConditionalFormatHighlightRuleBuilder
```

**Parameters**

* `operator` — Required. The operator to use for the average rule.

**Returns**

The conditional format highlight rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that highlights cells with greater than average values in red for the range A1:D10.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .setAverage(univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan)
  .setBackground('#FF0000')
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatHighlightRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts) · [`IAverageHighlightCell`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/models/type.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.setBackground`

Sets the background color for the conditional format rule's format.

```typescript
setBackground(color?: string): ConditionalFormatHighlightRuleBuilder
```

**Parameters**

* `color` — Optional. The background color to set. If not provided, the background color is removed.

**Returns**

The conditional format highlight rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that highlights cells with no content in red for the range A1:D10.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .whenCellEmpty()
  .setBackground('#FF0000')
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatHighlightRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.setBold`

Sets text bolding for the conditional format rule's format.

```typescript
setBold(isBold: boolean): ConditionalFormatHighlightRuleBuilder
```

**Parameters**

* `isBold` — Required. Whether to bold the text.

**Returns**

The conditional format highlight rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that bolds the text for cells with not empty content in the range A1:D10.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .whenCellNotEmpty()
  .setBold(true)
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatHighlightRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.setColorScale`

Set color scale rule.

```typescript
setColorScale(config: IColorScale['config']): ConditionalFormatColorScaleRuleBuilder
```

**Parameters**

* `config` — Required. The color scale rule settings.

**Returns**

The conditional format color scale rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that adds a color scale to cells with values between 0 and 100 in the range A1:D10.
// The color scale is green for 0, yellow for 50, and red for 100.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .setColorScale([
    { index: 0, color: '#00FF00', value: { type: 'num', value: 0 } },
    { index: 1, color: '#FFFF00', value: { type: 'num', value: 50 } },
    { index: 2, color: '#FF0000', value: { type: 'num', value: 100 } },
  ])
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatColorScaleRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts) · [`IColorScale`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/models/type.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.setDataBar`

Set data bar rule.

```typescript
setDataBar(config: { min: IValueConfig; max: IValueConfig; isGradient?: boolean; positiveColor: string; nativeColor: string; isShowValue?: boolean; }): ConditionalFormatDataBarRuleBuilder
```

**Parameters**

* `config` — Required. The data bar rule settings.

**Returns**

The conditional format data bar rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that adds a data bar to cells with values between -100 and 100 in the range A1:D10.
// positive values are green and negative values are red.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .setDataBar({
    min: { type: 'num', value: -100 },
    max: { type: 'num', value: 100 },
    positiveColor: '#00FF00',
    nativeColor: '#FF0000',
    isShowValue: true,
  })
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatDataBarRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts) · [`IValueConfig`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/models/type.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.setDuplicateValues`

Set duplicate values rule.

```typescript
setDuplicateValues(): ConditionalFormatHighlightRuleBuilder
```

**Returns**

The conditional format highlight rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that highlights cells with duplicate values in red for the range A1:D10.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .setDuplicateValues()
  .setBackground('#FF0000')
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatHighlightRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.setFontColor`

Sets the font color for the conditional format rule's format.

```typescript
setFontColor(color?: string): ConditionalFormatHighlightRuleBuilder
```

**Parameters**

* `color` — Optional. The font color to set. If not provided, the font color is removed.

**Returns**

The conditional format highlight rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that changes the font color to red for cells with not empty content in the range A1:D10.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .whenCellNotEmpty()
  .setFontColor('#FF0000')
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatHighlightRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.setIconSet`

Set up icon set conditional formatting rule.

```typescript
setIconSet(config: { iconConfigs: IIconSet['config']; isShowValue: boolean; }): ConditionalFormatIconSetRuleBuilder
```

**Parameters**

* `config` — Required. The icon set conditional formatting rule settings.

**Returns**

The conditional format icon set rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a 3-arrow icon set conditional formatting rule in the range A1:D10.
// The first arrow is green for values greater than 20.
// The second arrow is yellow for values greater than 10.
// The third arrow is red for values less than or equal to 10.
const fRange = fWorksheet.getRange('A1:D10')
const builder = fWorksheet.newConditionalFormattingRule()
console.log(builder.getIconMap()) // icons key-value map
const rule = builder
  .setIconSet({
    iconConfigs: [
      {
        iconType: univerAPI.Enum.ConditionFormatIconSetTypeEnum.threeArrows,
        iconId: '0',
        operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan,
        value: {
          type: univerAPI.Enum.ConditionFormatValueTypeEnum.num,
          value: 20,
        },
      },
      {
        iconType: univerAPI.Enum.ConditionFormatIconSetTypeEnum.threeArrows,
        iconId: '1',
        operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan,
        value: {
          type: univerAPI.Enum.ConditionFormatValueTypeEnum.num,
          value: 10,
        },
      },
      {
        iconType: univerAPI.Enum.ConditionFormatIconSetTypeEnum.threeArrows,
        iconId: '2',
        operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.lessThanOrEqual,
        value: {
          type: univerAPI.Enum.ConditionFormatValueTypeEnum.num,
          value: 10,
        },
      },
    ],
    isShowValue: true,
  })
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatIconSetRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts) · [`IIconSet`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/models/type.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.setItalic`

Sets text italics for the conditional format rule's format.

```typescript
setItalic(isItalic: boolean): ConditionalFormatHighlightRuleBuilder
```

**Parameters**

* `isItalic` — Required. Whether to italicize the text.

**Returns**

The conditional format highlight rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that italicizes the text for cells with not empty content in the range A1:D10.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .whenCellNotEmpty()
  .setItalic(true)
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatHighlightRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.setRank`

Set rank rule.

```typescript
setRank(config: { isBottom: boolean; isPercent: boolean; value: number; }): ConditionalFormatHighlightRuleBuilder
```

**Parameters**

* `config` — Required. The rank rule settings.

**Returns**

The conditional format highlight rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that highlights the bottom 10% of values in red for the range A1:D10.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .setRank({ isBottom: true, isPercent: true, value: 10 })
  .setBackground('#FF0000')
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatHighlightRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.setStrikethrough`

Sets text strikethrough for the conditional format rule's format.

```typescript
setStrikethrough(isStrikethrough: boolean): ConditionalFormatHighlightRuleBuilder
```

**Parameters**

* `isStrikethrough` — Required. Whether is strikethrough the text.

**Returns**

The conditional format highlight rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that set text strikethrough for cells with not empty content in the range A1:D10.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .whenCellNotEmpty()
  .setStrikethrough(true)
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatHighlightRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.setUnderline`

Sets text underlining for the conditional format rule's format.

```typescript
setUnderline(isUnderline: boolean): ConditionalFormatHighlightRuleBuilder
```

**Parameters**

* `isUnderline` — Required. Whether to underline the text.

**Returns**

The conditional format highlight rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that underlines the text for cells with not empty content in the range A1:D10.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .whenCellNotEmpty()
  .setUnderline(true)
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatHighlightRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.setUniqueValues`

Set unique values rule.

```typescript
setUniqueValues(): ConditionalFormatHighlightRuleBuilder
```

**Returns**

The conditional format highlight rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that highlights cells with unique values in red for the range A1:D10.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .setUniqueValues()
  .setBackground('#FF0000')
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatHighlightRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.whenCellEmpty`

Sets the conditional format rule to trigger when the cell is empty.

```typescript
whenCellEmpty(): ConditionalFormatHighlightRuleBuilder
```

**Returns**

The conditional format highlight rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that highlights cells with no content in red for the range A1:D10.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .whenCellEmpty()
  .setBackground('#FF0000')
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatHighlightRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.whenCellNotEmpty`

Sets the conditional format rule to trigger when the cell is not empty.

```typescript
whenCellNotEmpty(): ConditionalFormatHighlightRuleBuilder
```

**Returns**

The conditional format highlight rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that changes the font color to red for cells with not empty content in the range A1:D10.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .whenCellNotEmpty()
  .setFontColor('#FF0000')
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatHighlightRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.whenDate`

Sets the conditional format rule to trigger when a time period is met.

```typescript
whenDate(date: CFTimePeriodOperator): ConditionalFormatHighlightRuleBuilder
```

**Parameters**

* `date` — Required. The time period to check for.

**Returns**

The conditional format highlight rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that highlights cells with dates in the last 7 days in red for the range A1:D10.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .whenDate(univerAPI.Enum.ConditionFormatTimePeriodOperatorEnum.last7Days)
  .setBackground('#FF0000')
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatHighlightRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts) · [`CFTimePeriodOperator`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/base/const.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.whenFormulaSatisfied`

Sets the conditional format rule to trigger when that the given formula evaluates to `true`.

```typescript
whenFormulaSatisfied(formulaString: string): ConditionalFormatHighlightRuleBuilder
```

**Parameters**

* `formulaString` — Required. A custom formula that evaluates to true if the input is valid. formulaString start with '='.

**Returns**

The conditional format highlight rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that highlights cells with values greater than 10 in red for the range A1:D10.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .whenFormulaSatisfied('=A1>10')
  .setBackground('#FF0000')
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatHighlightRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.whenNumberBetween`

Sets the conditional format rule to trigger when a number falls between, or is either of, two specified values.

```typescript
whenNumberBetween(start: number, end: number): ConditionalFormatHighlightRuleBuilder
```

**Parameters**

* `start` — Required. The lowest acceptable value.
* `end` — Required. The highest acceptable value.

**Returns**

The conditional format highlight rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that highlights cells with values between 10 and 20 in red for the range A1:D10.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .whenNumberBetween(10, 20)
  .setBackground('#FF0000')
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatHighlightRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.whenNumberEqualTo`

Sets the conditional format rule to trigger when a number is equal to the given value.

```typescript
whenNumberEqualTo(value: number): ConditionalFormatHighlightRuleBuilder
```

**Parameters**

* `value` — Required. The sole acceptable value.

**Returns**

The conditional format highlight rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that highlights cells with values equal to 10 in red for the range A1:D10.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .whenNumberEqualTo(10)
  .setBackground('#FF0000')
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatHighlightRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.whenNumberGreaterThan`

Sets the conditional format rule to trigger when a number is greater than the given value.

```typescript
whenNumberGreaterThan(value: number): ConditionalFormatHighlightRuleBuilder
```

**Parameters**

* `value` — Required. The highest unacceptable value.

**Returns**

The conditional format highlight rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that highlights cells with values greater than 10 in red for the range A1:D10.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .whenNumberGreaterThan(10)
  .setBackground('#FF0000')
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatHighlightRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.whenNumberGreaterThanOrEqualTo`

Sets the conditional format rule to trigger when a number is greater than or equal to the given value.

```typescript
whenNumberGreaterThanOrEqualTo(value: number): ConditionalFormatHighlightRuleBuilder
```

**Parameters**

* `value` — Required. The lowest acceptable value.

**Returns**

The conditional format highlight rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that highlights cells with values greater than or equal to 10 in red for the range A1:D10.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .whenNumberGreaterThanOrEqualTo(10)
  .setBackground('#FF0000')
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatHighlightRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.whenNumberLessThan`

Sets the conditional conditional format rule to trigger when a number less than the given value.

```typescript
whenNumberLessThan(value: number): ConditionalFormatHighlightRuleBuilder
```

**Parameters**

* `value` — Required. The lowest unacceptable value.

**Returns**

The conditional format highlight rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that highlights cells with values less than 10 in red for the range A1:D10.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .whenNumberLessThan(10)
  .setBackground('#FF0000')
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatHighlightRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.whenNumberLessThanOrEqualTo`

Sets the conditional format rule to trigger when a number less than or equal to the given value.

```typescript
whenNumberLessThanOrEqualTo(value: number): ConditionalFormatHighlightRuleBuilder
```

**Parameters**

* `value` — Required. The highest acceptable value.

**Returns**

The conditional format highlight rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that highlights cells with values less than or equal to 10 in red for the range A1:D10.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .whenNumberLessThanOrEqualTo(10)
  .setBackground('#FF0000')
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatHighlightRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.whenNumberNotBetween`

Sets the conditional format rule to trigger when a number does not fall between, and is neither of, two specified values.

```typescript
whenNumberNotBetween(start: number, end: number): ConditionalFormatHighlightRuleBuilder
```

**Parameters**

* `start` — Required. The lowest unacceptable value.
* `end` — Required. The highest unacceptable value.

**Returns**

The conditional format highlight rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that highlights cells with values not between 10 and 20 in red for the range A1:D10.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .whenNumberNotBetween(10, 20)
  .setBackground('#FF0000')
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatHighlightRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.whenNumberNotEqualTo`

Sets the conditional format rule to trigger when a number is not equal to the given value.

```typescript
whenNumberNotEqualTo(value: number): ConditionalFormatHighlightRuleBuilder
```

**Parameters**

* `value` — Required. The sole unacceptable value.

**Returns**

The conditional format highlight rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that highlights cells with values not equal to 10 in red for the range A1:D10.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .whenNumberNotEqualTo(10)
  .setBackground('#FF0000')
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatHighlightRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.whenTextContains`

Sets the conditional format rule to trigger when that the input contains the given value.

```typescript
whenTextContains(text: string): ConditionalFormatHighlightRuleBuilder
```

**Parameters**

* `text` — Required. The value that the input must contain.

**Returns**

The conditional format highlight rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that highlights cells with text containing 'apple' in red for the range A1:D10.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .whenTextContains('apple')
  .setBackground('#FF0000')
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatHighlightRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.whenTextDoesNotContain`

Sets the conditional format rule to trigger when that the input does not contain the given value.

```typescript
whenTextDoesNotContain(text: string): ConditionalFormatHighlightRuleBuilder
```

**Parameters**

* `text` — Required. The value that the input must not contain.

**Returns**

The conditional format highlight rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that highlights cells with text not containing 'apple' in red for the range A1:D10.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .whenTextDoesNotContain('apple')
  .setBackground('#FF0000')
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatHighlightRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.whenTextEndsWith`

Sets the conditional format rule to trigger when that the input ends with the given value.

```typescript
whenTextEndsWith(text: string): ConditionalFormatHighlightRuleBuilder
```

**Parameters**

* `text` — Required. Text to compare against the end of the string.

**Returns**

The conditional format highlight rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that highlights cells with text ending with '.ai' in red for the range A1:D10.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .whenTextEndsWith('.ai')
  .setBackground('#FF0000')
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatHighlightRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.whenTextEqualTo`

Sets the conditional format rule to trigger when that the input is equal to the given value.

```typescript
whenTextEqualTo(text: string): ConditionalFormatHighlightRuleBuilder
```

**Parameters**

* `text` — Required. The sole acceptable value.

**Returns**

The conditional format highlight rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that highlights cells with text equal to 'apple' in red for the range A1:D10.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .whenTextEqualTo('apple')
  .setBackground('#FF0000')
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatHighlightRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

### `FConditionalFormattingBuilder.whenTextStartsWith`

Sets the conditional format rule to trigger when that the input starts with the given value.

```typescript
whenTextStartsWith(text: string): ConditionalFormatHighlightRuleBuilder
```

**Parameters**

* `text` — Required. Text to compare against the beginning of the string.

**Returns**

The conditional format highlight rule builder.

**Examples**

```ts
const fWorkbook = univerAPI.getActiveWorkbook()
const fWorksheet = fWorkbook.getSheetByName('Sheet1')
if (!fWorksheet) throw new Error('fWorksheet is not available')

// Create a conditional formatting rule that highlights cells with text starting with 'https://' in red for the range A1:D10.
const fRange = fWorksheet.getRange('A1:D10')
const rule = fWorksheet
  .newConditionalFormattingRule()
  .whenTextStartsWith('https://')
  .setBackground('#FF0000')
  .setRanges([fRange.getRange()])
  .build()
fWorksheet.addConditionalFormattingRule(rule)
```

**Types:** [`ConditionalFormatHighlightRuleBuilder`](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)

**Package:** [`@univerjs/sheets-conditional-formatting`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/sheets-conditional-formatting.md) · [Type definitions](https://unpkg.com/@univerjs/sheets-conditional-formatting@1.0.0-rc.0/lib/types/facade/f-conditional-formatting-builder.d.ts)
