TX Text Control .NET Server

Mail Merge and Reporting

Topic

Hundreds of invoices from one layout, a contract with only the clauses a customer needs, a report whose tables grow with its data: MailMerge produces them by merging templates with data. Going beyond a first merge means knowing the shapes of data and the options of fields and blocks, and building conditional content, images, barcodes and templates that hold up with real data.

If you haven't merged a template yet, start with Getting Started: Mail Merge. The MailMerge page in the Overview explains the class and where it runs.

How Mail Merge Works

A merge brings three parts together:

  • The template is a document designed in MS Word, in the Document Editor or in code. It contains merge fields for single values, merge blocks for repeating and optional sections, and placeholders for images and barcodes.
  • The data is prepared in the structure the document needs, as JSON, business objects or a DataSet. Its names match the names of the fields and blocks.
  • MailMerge fills the template held by a ServerTextControl with the data. The result is saved as PDF, DOCX or another format, as one document or as one document per record.

Formatting, layout and rules such as filters stay in the template, so the merge code doesn't change when a designer changes them.

Find the Right Page

If you want toRead
Understand the reporting model, create separate documents per record, follow a merge with events or merge in a Web APIOverview
Merge JSON, business objects, dictionaries or a DataSet, or load the same data into the Document EditorData Sources
Format numbers and dates, insert date fields, change merged fields in code or merge form fieldsMerge Fields
Repeat rows and sections for each record, or build master-detail reportsMerge Blocks, Nested Blocks
Merge logos, photos and QR codesImages, Barcodes
Include text and sections only when the data calls for themConditional Content
Merge the rows of a block in order and only the rows you needSorting and Filtering
Color rows, highlight values or calculate totals in merged tablesStyling
Design, store and test templates that merge wellTemplate Design
Try fields, blocks and rules step by step in an online demoTemplate Assistant

Where to Start

  1. Overview: how templates, data and the merge work together.
  2. Data Sources: the data your application merges.
  3. Merge Fields and Merge Blocks: the elements of every template.
  4. Template Design: templates that work with real data.