Table design
Create a banded report table
The template contains two differently styled rows. Merge the product data to repeat that pattern across the complete report.
Template patternRepeat two styled rows
A NEXT field advances the data record inside the alternating row pattern.
Banded tablePatternTwo rows
AdvanceNEXT field
StylingIn template
DataProduct array
Template structureUnderstand the current template
Explore its merge fields, repeating blocks, and nested structure in an interactive template map.
Inspector
Ready to tryUse the controls above to interact with this demo.
What this demonstrates
Keep presentation in the template
The merge block spans two table rows with the same fields but different background colors. A NEXT field at the end of the first row advances the data record inside the repeated pattern.
Application code supplies ordinary JSON. Row colors, typography, widths, and spacing remain editable in the Word-compatible template.
API used
MailMerge.MergeJsonData
Key members
The server supplies ordinary JSON; the two-row pattern and NEXT field remain entirely inside the reusable template.
using var textControl = new ServerTextControl();
textControl.Create();
using var mailMerge = new MailMerge
{
TextComponent = textControl,
RemoveEmptyBlocks = true
};
mailMerge.LoadTemplate(templatePath, FileFormat.InternalUnicodeFormat);
mailMerge.MergeJsonData(File.ReadAllText(dataPath));
mailMerge.SaveDocumentToMemory(
out byte[] document,
BinaryStreamType.InternalUnicodeFormat,
new SaveSettings());
How it works
MailMerge expands the two-row block until the matching data array is exhausted. The template's NEXT field makes the second row use the following data record.
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
Displays supported document and PDF formats in the browser.
dotnet add package TXTextControl.Web.DocumentViewer --version 34.2.0