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

# @reductoai/xlsx/editor

The headless sheet editor: commands, selection and undo over a workbook. Guide: [Headless editor](https://docs.reducto.ai/office/xlsx/ui/headless-editor.md).

## `XlsxEditor`

Home-tab edits of a workbook: every command acts on the selection through the `Excel.*` facade
and is one step of the same undo history the grid's typing uses.

Import from `@reductoai/xlsx/editor`.

### XlsxEditor properties

| Name | Type | Description |
| - | - | - |
| `session` | `EditSession` | read-only |
| `canPasteSpecial` | `boolean` | read-only |
| `canRedo` | `boolean` | read-only |
| `canRepeat` | `boolean` | read-only Repeat (F4, or Ctrl+Y with nothing to redo) runs the last command again while no other edit came after it. |
| `canUndo` | `boolean` | read-only |
| `clipboard` | `string` | read-only The text the last Copy or Cut gave, for the system clipboard. |
| `createNamesGuess` | `CreateNamesFrom` | read-only The sides Create from Selection starts with for the selection. |
| `groupAxis` | `Axis \| null` | read-only The axis Group and Ungroup take from whole selected lines; null when Excel asks Rows or Columns. |
| `replacedCount` | `number` | read-only How many cells the last Replace or Replace All changed. |
| `selection` | `EditorSelection` | read-only |
| `selectionRef` | `string` | read-only The selection as an absolute reference with its sheet, as New Name's Refers to starts. |
| `seriesGuess` | `Pick<FillSeries, "by" \| "type">` | read-only Series in and Type the Series window starts with for the selection. |
| `sheetChange` | `SheetChange \| null` | read-only Where the tabs went after the last command, when it added, removed, moved or hid a sheet. |
| `userName` | `string` | The name a new comment or reply is posted under. |
| `workbook` | `Workbook` | read-only |

### `apply()`

```ts theme={null}
apply(command: XlsxCommand): EditResult
```

### `arrows()`

```ts theme={null}
arrows(): TraceArrow[]
```

The tracer arrows on every sheet, as the grid paints them.

### `cellSizes()`

```ts theme={null}
cellSizes(): CellSizes
```

What Row Height, Column Width and Default Width show for the selection.

### `cfGuess()`

```ts theme={null}
cfGuess(): CfGuess
```

### `cfRules()`

```ts theme={null}
cfRules(scope: "selection" | "sheet"): CfRuleRow[]
```

Manage Rules' list: the rules that touch the selection, or every rule on its sheet.

### `chart()`

```ts theme={null}
chart(target: ChartTarget): ChartPane | null
```

The Format Chart pane of a chart on a sheet; null when it is not one.

### `chartData()`

```ts theme={null}
chartData(target: ChartTarget): ChartDataView | null
```

Select Data Source's fields for a chart on a sheet; null when it is not one.

### `chartSource()`

```ts theme={null}
chartSource(target: ChartTarget, part: string): ChartSourceBlock[]
```

The blocks a chart element reads (a series or its labels), on any sheet; none for other parts.

### `contextMenu()`

```ts theme={null}
contextMenu(target: GridMenuTarget): MenuEntry[]
```

Excel's right-click menu at `target`, as data; each entry's command goes back through `apply`.

### `filtered()`

```ts theme={null}
filtered(): boolean
```

Whether the active cell's table or the sheet has a filtered list, for Clear and Reapply.

### `find()`

```ts theme={null}
find(query: FindQuery, step?: -1 | 1): FoundCell | null
```

Find Next (`step` -1 for Find Previous): the match becomes the active cell; a searched block stays selected.

### `findAll()`

```ts theme={null}
findAll(query: FindQuery): FoundCell[]
```

Find All: every match in the scope, in search order.

### `format()`

```ts theme={null}
format(): CellFormat
```

The active cell's format.

### `frozen()`

```ts theme={null}
frozen(): Frozen
```

The panes frozen on the selected sheet.

### `gridlines()`

```ts theme={null}
gridlines(): boolean
```

Whether the selected sheet shows its gridlines.

### `headings()`

```ts theme={null}
headings(): boolean
```

Whether the selected sheet shows its row and column headings.

### `inTable()`

```ts theme={null}
inTable(): boolean
```

Whether the active cell sits in a table, so Clear Rules offers This Table.

### `link()`

```ts theme={null}
link(): CellLink | null
```

The active cell's link, or null.

### `mergeDiscards()`

```ts theme={null}
mergeDiscards(how?: MergeHow): boolean
```

Whether merging the selection would drop values other than each area's top-left one.

### `names()`

```ts theme={null}
names(): NameRow[]
```

The names Name Manager lists.

### `note()`

```ts theme={null}
note(): string | null
```

The active cell's note, or null.

### `noteShown()`

```ts theme={null}
noteShown(): boolean | null
```

Whether the active cell's note stays on the sheet; null without a note.

### `pageSetup()`

```ts theme={null}
pageSetup(): PageSetup
```

Page Setup's values for the active sheet.

### `read()`

```ts theme={null}
read<T>(reader: (session: EditSession, sel: EditorSelection) => T): T
```

Runs a dialog's reader (`advancedFilterGuess`, `removeDuplicatesGuess`) on the session and selection.

### `sample()`

```ts theme={null}
sample(code: string): string
```

The active cell's value as `code` shows it, for Format Cells' Sample.

### `scenarios()`

```ts theme={null}
scenarios(): ScenarioList
```

Scenario Manager's list for the active sheet.

### `scenarioValues()`

```ts theme={null}
scenarioValues(changing: string): { cell: string; value: string }[]
```

The current values of `changing`, as Add Scenario offers them.

### `slicerSettings()`

```ts theme={null}
slicerSettings(name: string): SlicerSettings | null
```

Slicer Settings for the slicer `name`; null when there is none.

### `sortGuess()`

```ts theme={null}
sortGuess(): SortGuess
```

What Sort opens with; throws where Excel refuses (a blank cell alone, a pivot).

### `sparkline()`

```ts theme={null}
sparkline(): SparkGroupState | null
```

The active cell's sparkline group, as the Sparkline tab shows it.

### `stepNote()`

```ts theme={null}
stepNote(step: -1 | 1): { c: number; r: number } | null
```

Review > Next (`step` -1 for Previous): the next note or comment's cell becomes active.

### `subtotalGuess()`

```ts theme={null}
subtotalGuess(): SubtotalGuess | null
```

Data > Subtotal's list and labels; null when the selection is not in a list.

### `tableGuess()`

```ts theme={null}
tableGuess(): TableGuess
```

Create Table's range and header guess; throws where Excel refuses (a blank cell alone).

### `textColumnsPreview()`

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

Text to Columns' preview rows; null when the selection spans columns.

### `thread()`

```ts theme={null}
thread(): CommentThread | null
```

The active cell's comment thread, or null.

### `usableNames()`

```ts theme={null}
usableNames(): { name: string; refersTo: string }[]
```

The names a formula on the selected sheet can use, as Use in Formula lists them.

### `validation()`

```ts theme={null}
validation(): ValidationState
```

The selection's rule as Data Validation opens with it.

## `contextMenu()`

```ts theme={null}
function contextMenu(editor: XlsxEditor, target: GridMenuTarget): MenuEntry[]
```

Excel's right-click menu for the target, over the editor's current selection.

Import from `@reductoai/xlsx/editor`.
