TX Sheet Control

Calculation Class

Class
Namespace
TXTextControl.TXSheetControl.Server
Package
TXTextControl.TXSheetControl.Server from the private NuGet feed or the supplied NuGet folder
Assembly
TXTextControl.TXSheetControl.Api.dll
Install
dotnet add package TXTextControl.TXSheetControl.Server .NET 10 and later.
Also in
TXTextControl.TXSheetControl.Blazor as TXTextControl.TXSheetControl.Api.dll
Inherits
  1. DocumentObject
  2. Calculation

Shared calculation settling, external documents and formula dependency auditing.

Syntax

public class Calculation

Members

Methods

MethodDescription
DependentsAsyncBuilds the sparse formula graph and returns direct dependent cell identities.
PrecedentsAsyncReturns direct precedent cell identities from the shared calculation graph.
RecalculateAsyncAwaits asynchronous formula dependencies until the shared document has stable calculated results.
RegisterFunctionAsyncRegisters an asynchronous host function. Results are JSON scalars or arrays; callbacks cannot reenter the control.
RemoveFunctionAsyncRemoves a function and releases its host delegate after invalidating dependent formulas.
SetExternalWorkbookAsyncBinds 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);
}

See Also