INTERACTIVE REPORTING
Merge formulas with live data
Review the merge fields and formulas in the invoice template, then merge the sample product data. The resulting document keeps its calculated totals.
What to look forThe quantity, unit price, discount, and line totals are merged values. The subtotal and total rows are calculated from formulas in the document.
Ready to tryUse the controls above to interact with this demo.
What this demonstrates
Mail Merge and formulas
A Word-compatible template can combine reporting fields with Excel-compatible formulas. This lets the document define both its data layout and its calculations.
Server-side merge
MailMerge.Merge
Save the current template
TXTextControl.saveDocument
Formula values
TableCell.getFormula / getText
How it works
The editor starts with mailmerge_formulas.tx. It contains merge fields for invoice items and formula cells for line totals, subtotals, and the final amount. Because the document is editable, you can change a formula before merging.
When Merge template is clicked, the browser saves the current document with TXTextControl.saveDocument and sends it to the demo-specific controller. The controller loads it into a ServerTextControl, creates a DocumentServer.MailMerge, and merges the sample DataSet from data.xml.
Mail Merge replaces the fields and repeating item block. Formula cells remain part of the document and recalculate from the merged values. The returned internal document is loaded back into the editor so the merged result can be inspected immediately.
TXTextControl.saveDocument(
TXTextControl.StreamType.InternalUnicodeFormat,
event => fetch("/merge", {
method: "POST",
body: JSON.stringify({ document: event.data })
}));
using var mailMerge = new DocumentServer.MailMerge {
TextComponent = textControl
};
mailMerge.Merge(data.Tables[0]);
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