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

Shared editing: a replica of the workbook that merges the edits of other users.

## `XlsxReplica`

Shared editing for workbooks: a workbook's edits as changes for a central
sequencer, and other writers' changes written back in. Pure and browser-safe, with no
DOM types, so a server writer loads it; `XlsxEditorCollab` is in `@reductoai/xlsx/editor`.

Import from `@reductoai/xlsx/collab`.

### XlsxReplica properties

| Name | Type | Description |
| - | - | - |
| `client` | `CollabClient` | read-only |
| `workbook` | `Workbook` | read-only |
| `pending` | `boolean` | read-only |
| `seq` | `number` | read-only |

### `XlsxReplica.ack()`

```ts theme={null}
ack(seq: number): void
```

### `XlsxReplica.cells()`

```ts theme={null}
cells(part: string): Record<string, string>
```

Every cell of a sheet as it travels, for a convergence check.

### `XlsxReplica.close()`

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

### `XlsxReplica.commit()`

```ts theme={null}
commit(): CollabChange
```

Reads local edits since the last call and hands them to the client; returns what was read.

### `XlsxReplica.decoded()`

```ts theme={null}
decoded(part: string): Decoded | undefined
```

The mirror's view of a part, for a convergence check.

### `XlsxReplica.parts()`

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

Every part the mirror holds, for a convergence check.

### `XlsxReplica.remote()`

```ts theme={null}
remote(change: CollabChange, seq: number): RemoteApplied
```

Another writer's change sequenced as `seq`; returns the parts it rewrote and the rows and columns it moved.

### `XlsxReplica.resend()`

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

## `XlsxReplicaOptions`

Shared editing for workbooks: a workbook's edits as changes for a central
sequencer, and other writers' changes written back in. Pure and browser-safe, with no
DOM types, so a server writer loads it; `XlsxEditorCollab` is in `@reductoai/xlsx/editor`.

Import from `@reductoai/xlsx/collab`.

| Name | Type | Description |
| - | - | - |
| `block?` | `number` | This writer's id block (1 and up), unique among the writers of the workbook; absent for a reader, who mints no ids. |
| `send` | `(out: Outgoing) => void` | |
| `seq` | `number` | Sequence number of the server change the workbook reflects. |

## `XlsxEditorCollab`

Import from `@reductoai/xlsx/editor`.

### XlsxEditorCollab properties

| Name | Type | Description |
| - | - | - |
| `editor` | `XlsxEditor` | read-only |
| `presence` | `PresenceTable<XlsxPresence> \| undefined` | read-only |
| `replica` | `XlsxReplica` | read-only |

### `XlsxEditorCollab.ack()`

```ts theme={null}
ack(seq: number): void
```

### `XlsxEditorCollab.apply()`

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

### `XlsxEditorCollab.close()`

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

### `XlsxEditorCollab.leave()`

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

Tells the others this writer left.

### `XlsxEditorCollab.location()`

```ts theme={null}
location(): XlsxPresence
```

This writer's place as it travels.

### `XlsxEditorCollab.peers()`

```ts theme={null}
peers(): XlsxPeerMark[]
```

Every other writer whose sheet still exists.

### `XlsxEditorCollab.publish()`

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

### `XlsxEditorCollab.receivePresence()`

```ts theme={null}
receivePresence(update: PresenceUpdate<XlsxPresence>): boolean
```

Takes another writer's place; true when the marks changed.

### `XlsxEditorCollab.remote()`

```ts theme={null}
remote(change: CollabChange, seq: number): XlsxRemote
```

Another writer's change; the editor's selection follows its cells.

### `XlsxEditorCollab.resend()`

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

### `XlsxEditorCollab.settle()`

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

Sends what the editor did outside `apply` (the grid's typing, a script) and its place.
