Live document calculations
Explore Excel-compatible formulas
Edit an input value in the cash-flow table, inspect how formula cells reference it, and watch calculated results update inside the document.
Ready to tryUse the controls above to interact with this demo.
What this demonstrates
Tables can carry their own calculation logic
TX Text Control combines word-processing layout with spreadsheet-style calculations. A table cell can store an Excel-compatible formula, reference other cells in the same table, and automatically update its displayed text whenever an input changes.
Formula expression
TableCell.getFormula / setFormula
Calculated result
TableCell.getText
Cell location
TableCell.getRow / getColumn / getName
Cell at the caret
TableCellCollection.getItemAtInputPosition
Reference notation
TXTextControl.setFormulaReferenceStyle
How it works
The template contains a cash-flow table with ordinary input cells and green calculation cells. Each result cell stores its expression independently through TableCell.setFormula; the calculated value is returned as the cell's text through TableCell.getText.
Formula references are scoped to the same table. With FormulaReferenceStyle.A1, B3 identifies column B and row 3. FormulaReferenceStyle.R1C1 expresses the same cell as R3C2 and additionally supports relative coordinates such as R[-1]C[-2].
The panel enumerates TXTextControl.tables and each table's cell collection. Cells with a non-empty getFormula result become entries in the formula map; their expression is parsed only for visualization while TX Text Control remains the calculation engine.
Calling TableCell.select moves the editor to a chosen calculation. Applying an edited expression with setFormula immediately recalculates that cell and any formulas that depend on it.
The synchronization also works in the opposite direction. On inputPositionChanged, TXTextControl.tables.getItem finds the table at the caret and TableCellCollection.getItemAtInputPosition returns its current cell. Its document start position, row, and column identify the corresponding entry in the formula map.
The Formula ribbon tab exposes the same capabilities interactively and includes more than one hundred mathematical, statistical, logical, and trigonometric functions compatible with common spreadsheet workflows.
const formula = await request(cell, "getFormula");
const result = await request(cell, "getText");
console.log({ formula, result });
await request(cell, "setFormula", "=SUM(B2:B6)");
const recalculated = await request(cell, "getText");
await request(
TXTextControl,
"setFormulaReferenceStyle",
TXTextControl.FormulaReferenceStyle.R1C1);
TXTextControl.tables.getItem(table => {
table?.cells.getItemAtInputPosition(cell => {
if (cell) synchronizeFormulaInspector(table, cell);
});
});
NuGet packages
TXTextControl.TextControl.Core.SDK
34.0.4
Provides the core document model and server-side document processing APIs.
dotnet add package TXTextControl.TextControl.Core.SDK --version 34.0.4
Provides the browser-based TX Text Control document editor and JavaScript API.
dotnet add package TXTextControl.Web --version 34.4.0
TXTextControl.Web.DocumentEditor.Backend
34.4.0
Hosts the WebSocket-based backend used by the browser document editor.
dotnet add package TXTextControl.Web.DocumentEditor.Backend --version 34.4.0