# WorkbookCalculation Class

> WorkbookCalculation class in the Node.js TypeScript API: Per-document function registration, asynchronous settling, external documents and formula auditing.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Class
- **Path:** TX Sheet Control > API Reference > TypeScript API > Node.js Server > WorkbookCalculation Class
- **911 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbookcalculation/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbookcalculation/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbookcalculation/llms-full.txt

---

Per-document function registration, asynchronous settling, external documents and formula auditing.

Package: `@txtextcontrol/tx-sheet-control-server`. Version: **2.0.0**.

Related workbook object-model type, returned through the server control. Obtain it from its owning workbook or collection; it is not a required browser-package import.

### Constructor

```typescript
new WorkbookCalculation(workbook: Workbook): WorkbookCalculation
```

| Parameter | Type | Optional | Description |
|---|---|---|---|
| `workbook` | `Workbook` | No | Value matching workbook's declared type and the owning object's validation rules. |

Returns: `WorkbookCalculation`.

### Members

#### Methods

| Method | Description |
|---|---|
| [dependents](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbookcalculation/dependents-method/llms-full.txt) | Builds the sparse formula graph and returns direct dependents of the requested cell. |
| [precedents](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbookcalculation/precedents-method/llms-full.txt) | Returns the cells read by the current formula, in stable identity order. |
| [recalculateAsync](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbookcalculation/recalculateasync-method/llms-full.txt) | Recalculates all formulas, awaiting asynchronous dependencies until the document becomes stable. |
| [registerFunction](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbookcalculation/registerfunction-method/llms-full.txt) | Registers a callback, including Promise results. Registration changes invalidate all formula caches. |
| [removeFunction](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbookcalculation/removefunction-method/llms-full.txt) | Removes a registered callback; subsequent formulas report #NAME? if no built-in function exists. |
| [setExternalWorkbook](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbookcalculation/setexternalworkbook-method/llms-full.txt) | Binds a snapshot of an already loaded workbook. Load files through workbook.load first. |

### Examples

Use a fresh workbook. Create and format the sample data, apply this API and retain the returned document or result in your application. In the browser pass editor.workbook; in Node.js pass the server control.

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

async function createWorkbookCalculationReport(control: ServerSheetControl) {
    const book = control.workbook;
    const sheet = book.sheets.at(0);
    sheet.cell('A1').setText('October invoice');
    sheet
        .cell('A1')
        .format({
            fontFamily: 'Liberation Sans',
            fontSize: 16,
            bold: true,
            textColor: '#ffffff',
            fillColor: '#163b63',
        });

    sheet.columns.at(0).setWidth({ pixels: 240 });
    sheet.range('B8:B9').setValues([[120], [80]]);
    sheet.cell('B10').setFormula('=SUM(B8:B9)');
    sheet.range('B8:B10').format({ numberFormatCode: '#,##0.00', fontSize: 11 });
    await book.calculation.recalculateAsync();
    return sheet;
}
```

### See Also

- [TypeScript Node.js Server API](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/llms-full.txt)
- [Formulas](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/formulas/llms-full.txt)

---

## In This Section

- [WorkbookCalculation.dependents Method](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbookcalculation/dependents-method/llms-full.txt): WorkbookCalculation.dependents method in the Node.js TypeScript API: Builds the sparse formula graph and returns direct dependents of the requested cell.
- [WorkbookCalculation.precedents Method](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbookcalculation/precedents-method/llms-full.txt): WorkbookCalculation.precedents method in the Node.js TypeScript API: Returns the cells read by the current formula, in stable identity order.
- [WorkbookCalculation.recalculateAsync Method](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbookcalculation/recalculateasync-method/llms-full.txt): WorkbookCalculation.recalculateAsync method in the Node.js TypeScript API, with the parameter options, the return type Promise<void> and a TypeScript example.
- [WorkbookCalculation.registerFunction Method](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbookcalculation/registerfunction-method/llms-full.txt): WorkbookCalculation.registerFunction method in the TX Sheet Control TypeScript API for Node.js: Registers a callback, including Promise results.
- [WorkbookCalculation.removeFunction Method](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbookcalculation/removefunction-method/llms-full.txt): WorkbookCalculation.removeFunction method in the TX Sheet Control TypeScript API for Node.js: Removes a registered callback.
- [WorkbookCalculation.setExternalWorkbook Method](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbookcalculation/setexternalworkbook-method/llms-full.txt): WorkbookCalculation.setExternalWorkbook method in the TX Sheet Control TypeScript API for Node.js: Binds a snapshot of an already loaded workbook.

---

## Nearby

- **Previous:** [Workbook.pivotTables Property](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbook/pivottables-property/llms-full.txt)
- **Next:** [WorkbookCalculation.dependents Method](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/nodejs/workbookcalculation/dependents-method/llms-full.txt)
