Calculation Class
- Namespace
TXTextControl.TXSheetControl. Server
- Package
TXTextControl.from the private NuGet feed or the supplied NuGet folderTXSheetControl. Server
- Assembly
TXTextControl.TXSheetControl. Api. dll
- Install
dotnet add package TXTextControl..NET 10 and later.TXSheetControl. Server
- Also in
TXTextControl.asTXSheetControl. Blazor TXTextControl.TXSheetControl. Api. dll
- Inherits
- Document
Object - Calculation
- Document
Shared calculation settling, external documents and formula dependency auditing.
Syntax
public class Calculation
Members
Methods
| Method | Description |
|---|---|
| DependentsAsync | Builds the sparse formula graph and returns direct dependent cell identities. |
| PrecedentsAsync | Returns direct precedent cell identities from the shared calculation graph. |
| RecalculateAsync | Awaits asynchronous formula dependencies until the shared document has stable calculated results. |
| RegisterFunctionAsync | Registers an asynchronous host function. Results are JSON scalars or arrays; callbacks cannot reenter the control. |
| RemoveFunctionAsync | Removes a function and releases its host delegate after invalidating dependent formulas. |
| SetExternalWorkbookAsync | 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.
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);
}