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

# Headless editor

`XlsxEditor` from `@reductoai/xlsx/editor` is the editor without a UI. It holds a selection and runs Home-tab commands on it, with undo and redo. The editor UI runs on it; you can also use it in Node or in tests.

```ts theme={null}
import { Workbook } from "@reductoai/xlsx";
import { XlsxEditor } from "@reductoai/xlsx/editor";

const editor = new XlsxEditor(Workbook.open(bytes));
editor.apply({ type: "select", r1: 1, c1: 1, r2: 2, c2: 3 }); // A1:C2; one-based
editor.apply({ type: "toggle", mark: "bold" });
editor.apply({ type: "fill", color: "#FFFF00" });
editor.apply({ type: "numberFormat", code: "#,##0.00" });
console.log(editor.format().bold, editor.canUndo); // true true
editor.apply({ type: "undo" });
const out = editor.workbook.save();
```

> [!NOTE]
>
> Rows and columns in commands are one-based, as in R1C1 notation. The core `Worksheet` methods are zero-based.

## Commands

Each command is an `XlsxCommand` object with a `type`. The main ones:

| `type` | What it does |
| - | - |
| `select` | Select a block (`r1`, `c1`, `r2`, `c2`) |
| `font` | Font name, size or color |
| `toggle` | Bold, italic, underline or strikethrough |
| `fill` | Fill color, or `null` for none |
| `align`, `wrap`, `indent`, `orientation` | Alignment |
| `merge` | Merge & Center and its forms |
| `numberFormat` | A number format code |
| `borders` | A border preset |
| `clear` | Clear all, formats, contents, comments or links |
| `insert`, `delete` | Insert or delete cells, rows or columns |
| `autoSum` | AutoSum and its functions |
| `copy`, `cut`, `paste` | Clipboard |
| `undo`, `redo` | History |

`apply` returns the block of cells it changed, or `null`. A command that Microsoft Excel refuses throws an error.
