> ## 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

## Conditional formats

```ts theme={null}
import { ExcelWorkbook } from "@reductoai/xlsx/officejs";

const book = ExcelWorkbook.fromBytes(bytes);
const sheet = book.worksheets.getItem("Sheet1");
const low = sheet.getRange("D2:D20").conditionalFormats.add("CellValue");
low.cellValue.rule = { formula1: "20", operator: "LessThan" };
low.cellValue.format.fill.color = "#F8CBAD";
```

## Data validation

```ts theme={null}
import { ExcelWorkbook } from "@reductoai/xlsx/officejs";

const book = ExcelWorkbook.fromBytes(bytes);
const sheet = book.worksheets.getItem("Sheet1");
sheet.getRange("E2:E20").dataValidation.rule = {
  list: { inCellDropDown: true, source: "Open,Closed" },
};
```
