# Workbook.batch Method

> Workbook.batch method in the Node.js TypeScript API: Runs an action as one batch with an optional source string and returns void, with a TypeScript example.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Method
- **Path:** TX Sheet Control > API Reference > TypeScript API > Node.js Server > Workbook > Workbook.batch Method
- **501 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbook/batch-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbook/batch-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbook/batch-method/llms-full.txt

---

The batch operation of Workbook.

Owner: [Workbook](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbook/llms-full.txt). Package: `@txtextcontrol/tx-sheet-control-server`. Version: **2.0.0**.

### Syntax

```typescript
batch(action: () => void, source?: string): void
```

### Parameters

| Parameter | Type | Optional | Description |
|---|---|---|---|
| `action` | `() => void` | No | Value matching action's declared type and the owning object's validation rules. |
| `source` | `string \| undefined` | Yes | Source data or object as described by the parameter type. |

### Return Value

`void`.

### Examples

Use a fresh sample workbook for this example. In the browser pass editor.workbook; in Node.js pass the server control. Document-bound objects are obtained from that same owner.

```typescript
import type { ServerSheetControl } from '@txtextcontrol/tx-sheet-control-server';

function updateInvoiceAtomically(control: ServerSheetControl) {
    const book = control.workbook;
    const sheet = book.sheets.at(0);
    book.batch(() => {
        sheet.cell('B8').setValue(120);
        sheet.cell('B9').setValue(80);
        sheet.cell('B10').setFormula('=SUM(B8:B9)');
    });
}
```

### Remarks

Use this member on an object from the current document. Reacquire document-bound handles after replacement/deletion. Validate arguments against the declared types and documented bounds; handle exceptions or rejected promises.

### See Also

- [Workbook Class](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbook/llms-full.txt)
- [Workbooks and Worksheets](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/workbooks/llms-full.txt)

---

## Nearby

- **Previous:** [Workbook.autoExpand Property](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbook/autoexpand-property/llms-full.txt)
- **Next:** [Workbook.calculation Property](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbook/calculation-property/llms-full.txt)
