Mail Merge and Reporting
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. MailMergefills the template held by aServerTextControlwith 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 to | Read |
|---|---|
| Understand the reporting model, create separate documents per record, follow a merge with events or merge in a Web API | Overview |
Merge JSON, business objects, dictionaries or a DataSet, or load the same data into the Document Editor | Data Sources |
| Format numbers and dates, insert date fields, change merged fields in code or merge form fields | Merge Fields |
| Repeat rows and sections for each record, or build master-detail reports | Merge Blocks, Nested Blocks |
| Merge logos, photos and QR codes | Images, Barcodes |
| Include text and sections only when the data calls for them | Conditional Content |
| Merge the rows of a block in order and only the rows you need | Sorting and Filtering |
| Color rows, highlight values or calculate totals in merged tables | Styling |
| Design, store and test templates that merge well | Template Design |
| Try fields, blocks and rules step by step in an online demo | Template Assistant |
Where to Start
- Overview: how templates, data and the merge work together.
- Data Sources: the data your application merges.
- Merge Fields and Merge Blocks: the elements of every template.
- Template Design: templates that work with real data.