# WorkbookCalculation Class

> WorkbookCalculation class in the browser JavaScript 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 > JavaScript API > Browser Editor > WorkbookCalculation Class
- **887 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/workbookcalculation/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/workbookcalculation/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/workbookcalculation/llms-full.txt

---

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

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

ES module import: `import { WorkbookCalculation } from '@txtextcontrol/tx-sheet-control';`.

### Constructor

```javascript
new WorkbookCalculation(workbook)
```

| 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/javascript-api/browser/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/javascript-api/browser/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/javascript-api/browser/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/javascript-api/browser/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/javascript-api/browser/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/javascript-api/browser/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.

```javascript
async function createWorkbookCalculationReport(book) {
    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

- [JavaScript Browser Editor API](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/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/javascript-api/browser/workbookcalculation/dependents-method/llms-full.txt): WorkbookCalculation.dependents method in the browser JavaScript 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/javascript-api/browser/workbookcalculation/precedents-method/llms-full.txt): WorkbookCalculation.precedents method in the browser JavaScript API: Returns the cells read by the current formula, in stable identity order.
- [WorkbookCalculation.recalculateAsync Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/workbookcalculation/recalculateasync-method/llms-full.txt): WorkbookCalculation.recalculateAsync method in the browser JavaScript API, with the parameter options, the return type Promise<void> and a JavaScript example.
- [WorkbookCalculation.registerFunction Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/workbookcalculation/registerfunction-method/llms-full.txt): WorkbookCalculation.registerFunction method in the TX Sheet Control JavaScript API for the browser: Registers a callback, including Promise results.
- [WorkbookCalculation.removeFunction Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/workbookcalculation/removefunction-method/llms-full.txt): WorkbookCalculation.removeFunction method in the TX Sheet Control JavaScript API for the browser: Removes a registered callback.
- [WorkbookCalculation.setExternalWorkbook Method](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/workbookcalculation/setexternalworkbook-method/llms-full.txt): WorkbookCalculation.setExternalWorkbook method in the TX Sheet Control JavaScript API for the browser: Binds a snapshot of an already loaded workbook.

---

## Nearby

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