# Merge Policies and Template Design

> Design mail merge templates for real data: safe binding paths and types, MailMergeOptions policies for missing and null values, repeat bands, TXWB and batches.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Sheet Control > Mail Merge > Merge Policies and Template Design
- **1008 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/mail-merge/template-design/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/mail-merge/template-design/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/mail-merge/template-design/llms-full.txt

---

A report template combines values, formulas, styles, print settings and declarative bindings. Plan its fixed cells and row bands before you add application data. Read on for the binding paths and types, the policies for missing data, the layout of repeat bands, persistence and batches.

### Use Safe Paths and Types

Binding paths use the documented safe property-path grammar. Avoid:

- prototype-related keys,
- unsupported property names,
- the assumption that every arbitrary JSON key can become a field path.

Choose the type of every binding intentionally: `string`, `number`, `boolean` or the supported ISO date type `date-iso`, the values of [MailMergeBinding.type](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/mailmergebinding/type-property/llms-full.txt).

### Choose Policies for Missing Data

Missing fields, null values and empty arrays are different conditions. [MailMergeOptions](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/mailmergeoptions/llms-full.txt) controls the supported policies for missing and null values and the maximum number of repeat items:

| Property | Values |
|---|---|
| [missing](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/mailmergeoptions/missing-property/llms-full.txt) | `"error"` or `"clear"` |
| [nulls](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/mailmergeoptions/nulls-property/llms-full.txt) | `"error"`, `"clear"` or `"preserve"` |
| [maxRepeatItems](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/mailmergeoptions/maxrepeatitems-property/llms-full.txt) | A number |

Select an error policy when absent mandatory data must reject the report rather than silently clear a cell.

### Design the Repeat Bands

A repeat block expands a band of template rows for each element of an array. Design its bands and mappings with these rules:

- **Bands.** Define non-overlapping template bands and valid mappings.
- **Anchors.** Field anchors refer to the original template coordinates.
- **Input cells.** Bind non-formula input cells. Formulas remain formulas and adjust with the supported row expansion.
- **Multi-row templates.** They need intentional mappings for each row.
- **Nested arrays.** Nested repeating arrays are not interchangeable with ordinary flat repeat blocks.
- **Structures.** Avoid blocks that split protected or merged structures or rely on unsupported table and layout combinations.
- **Limits.** Validate the limits before you expand a large array.

Test every template with one item, multiple items and zero items.

> Warning
>
> **Merge From a Clean Template.** Reusable template capture preserves a clean starting point. Do not build a second merge from rows that are already expanded.

### Recognize Fields and Blocks in the Editor

Bound merge fields have a subtle blue tint and an accent marker inside the cell. Fields in a repeat block use purple, and a dashed purple outline identifies the complete block range. Selecting any cell inside that range, including a formula cell without a field binding, changes the outline to a solid highlight and shows the array path beside the block when space permits. The normal cell selection frame remains visible.

The guides follow the template metadata, not the displayed placeholder text. Typing `«customer.name»` by itself does not create a binding or a guide. Scrolling, zooming, frozen or split panes, and Page Layout view keep the guides aligned with the cells.

These are editor cues: they do not change cell values, formulas or formatting, and they are not included in PDF or XLSX output. Removing the template metadata removes its guides. Merged output without template bindings has no guides.

### Persist the Template and Check the Output

Use TXWB to retain the supported template bindings. Application records and callbacks are not automatically embedded as executable registrations.

After a merge, check the merge warnings, the formula errors and the repeated ranges. Then verify the page breaks, the totals, the fonts and the output type.

### Process Batches of Invoices

For batch invoices, isolate the records and release the output workbooks according to the lifetime API of the package. A failed record should not corrupt the template of another record.

### Next Steps

- [Lifetime and Concurrency](https://docs.textcontrol.com/tx-sheet-control/document-processing/lifetime/llms-full.txt): release workbooks and controls and keep unrelated jobs apart.
- [Backend Services](https://docs.textcontrol.com/tx-sheet-control/document-processing/backend-services/llms-full.txt): create reports in a .NET or Node.js backend without a browser.
- [Mail Merge With JSON](https://docs.textcontrol.com/tx-sheet-control/mail-merge/overview/llms-full.txt): define bindings and repeat blocks and merge a record in the browser, Node.js or .NET.

### Barcode Labels

A cell barcode retains the merge field value or formula beneath it. Repeating blocks also copy floating barcodes anchored inside their template range and adjust relative sources per record. Use string fields for identifiers with leading zeros. See [Barcodes and QR Codes](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/barcodes/llms-full.txt) for a complete repeating-label example and XLSX compatibility details.

---

## Nearby

- **Previous:** [Mail Merge With JSON](https://docs.textcontrol.com/tx-sheet-control/mail-merge/overview/llms-full.txt)
- **Next:** [Invoice Report Pipeline](https://docs.textcontrol.com/tx-sheet-control/mail-merge/report-pipeline/llms-full.txt)
