# Calculation Class

> Calculation class in the TX Sheet Control .NET API: Shared calculation settling, external documents and formula dependency auditing.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Class
- **Namespace:** `TXTextControl.TXSheetControl.Server`
- **Package:** `TXTextControl.TXSheetControl.Server` (assembly `TXTextControl.TXSheetControl.Api.dll`, from the private NuGet feed or the supplied NuGet folder)
- **Package:** `TXTextControl.TXSheetControl.Blazor` (assembly `TXTextControl.TXSheetControl.Api.dll`, from the private NuGet feed or the supplied NuGet folder)
- **Inherits:** `TXTextControl.TXSheetControl.Server.DocumentObject`
- **Path:** TX Sheet Control > API Reference > .NET API > TXTextControl.TXSheetControl.Server > Calculation Class
- **882 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/calculation/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/calculation/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/calculation/llms-full.txt

---

Shared calculation settling, external documents and formula dependency auditing.

### Syntax

```csharp
public class Calculation
```

### Members

#### Methods

| Method | Description |
|---|---|
| [DependentsAsync](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/calculation/dependentsasync-method/llms-full.txt) | Builds the sparse formula graph and returns direct dependent cell identities. |
| [PrecedentsAsync](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/calculation/precedentsasync-method/llms-full.txt) | Returns direct precedent cell identities from the shared calculation graph. |
| [RecalculateAsync](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/calculation/recalculateasync-method/llms-full.txt) | Awaits asynchronous formula dependencies until the shared document has stable calculated results. |
| [RegisterFunctionAsync](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/calculation/registerfunctionasync-method/llms-full.txt) | Registers an asynchronous host function. Results are JSON scalars or arrays; callbacks cannot reenter the control. |
| [RemoveFunctionAsync](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/calculation/removefunctionasync-method/llms-full.txt) | Removes a function and releases its host delegate after invalidating dependent formulas. |
| [SetExternalWorkbookAsync](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/calculation/setexternalworkbookasync-method/llms-full.txt) | Binds a snapshot of an already loaded workbook; use LoadAsync to open its source file first. |

### Examples

Build a small report using this document API and return its PDF bytes. Pass a live control with a fresh workbook; the caller owns its lifetime.

```csharp
using TXTextControl.TXSheetControl.Server;

async Task<byte[]> CreateCalculationReportAsync(ServerSheetControl control)
{
    var book = control.Workbook;
    var sheet = await book.Sheets.AtAsync(0);
    await sheet.Cell("B8").SetValueAsync(120);
    await sheet.Cell("B9").SetValueAsync(80);
    await sheet.Cell("B10").SetFormulaAsync("=SUM(B8:B9)");

    var calculation = book.Calculation;
    await calculation.RecalculateAsync();
    return await control.SaveAsync(StreamType.PDF);
}
```

### See Also

- [TXTextControl.TXSheetControl.Server Namespace](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/llms-full.txt)
- [Formulas](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/formulas/llms-full.txt)

---

## In This Section

- [Calculation.DependentsAsync Method](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/calculation/dependentsasync-method/llms-full.txt): Calculation.DependentsAsync method in the TX Sheet Control .NET API: Builds the sparse formula graph and returns direct dependent cell identities.
- [Calculation.PrecedentsAsync Method](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/calculation/precedentsasync-method/llms-full.txt): Calculation.PrecedentsAsync method in the TX Sheet Control .NET API: Returns direct precedent cell identities from the shared calculation graph.
- [Calculation.RecalculateAsync Method](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/calculation/recalculateasync-method/llms-full.txt): Calculation.RecalculateAsync method in the .NET API: Awaits asynchronous formula dependencies until the shared document has stable calculated results.
- [Calculation.RegisterFunctionAsync Method](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/calculation/registerfunctionasync-method/llms-full.txt): Calculation.RegisterFunctionAsync method in the TX Sheet Control .NET API: Registers an asynchronous host function. Results are JSON scalars or arrays.
- [Calculation.RemoveFunctionAsync Method](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/calculation/removefunctionasync-method/llms-full.txt): Calculation.RemoveFunctionAsync method in the .NET API: Removes a function and releases its host delegate after invalidating dependent formulas.
- [Calculation.SetExternalWorkbookAsync Method](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/calculation/setexternalworkbookasync-method/llms-full.txt): Calculation.SetExternalWorkbookAsync method in the TX Sheet Control .NET API: Binds a snapshot of an already loaded workbook.

---

## Nearby

- **Previous:** [AnalyticsSource.TableId Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticssource/tableid-property/llms-full.txt)
- **Next:** [Calculation.DependentsAsync Method](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/calculation/dependentsasync-method/llms-full.txt)
