TX Sheet Control

Mail Merge

Topic

Mail merge fills a workbook template from JSON records: fixed bindings write customer and header fields, and repeat blocks expand a template row band for arrays such as invoice lines. Test every template with one item, two items and an empty item array. Each of the three exposes different problems in field paths, repeat expansion, formulas and layout.

A Customer or Header Field Is Blank

Check the fixed binding path against the shape of the supplied record, and the policy for missing and null values. MailMergeOptions sets the supported missing and null policies.

Item Fields Are Blank

Check the source array of the repeat block, and that the field paths inside the block are relative to the item.

A Formula Is Replaced by Text

A field mapping must target an input cell, not a cell intended to hold a formula. Bind the input cells, and the formulas remain formulas.

Rows Are Duplicated or Extra Rows Appear

Start each unrelated merge from the clean original template or from the captured one, not from a document that a previous merge has already expanded. In the browser, createMailMergeTemplate captures a reusable template. In .NET, load the template again before you process another unrelated record.

The Total Is Wrong

Check the formula range after the expansion, the numeric input types and the formula diagnostics of the merge.

Template Metadata Is Missing

Preserve the authoring template in TXWB, which retains the supported template bindings.

The Browser PDF Reports a Missing Font Host

The independent result workbook of a browser merge has no browser font host. Do one of the following:

  • Load the merged result into an initialized editor with fonts, and export the PDF through that editor.
  • Use a server control instead.

Mail Merge With JSON shows the browser code that loads the result into the editor and saves the PDF.

The Amount Column Prints on Another Page

Set the paper, the margins, the print area and fit-to-width deliberately. Page Layout and Print Settings shows the settings.

Validate the Result Before Delivery

  • Warnings are actionable output. Record their safe summaries, and inspect formula errors instead of suppressing them.
  • Template ranges must be valid, must not overlap and must be compatible with merged cells, tables and protection.
  • Nested arrays. Arbitrary nested arrays do not automatically become nested repeat structures.

Keep Data and Templates Apart

Application data and template documents are separate inputs. A TXWB need not contain private customer records to describe its bindings.

Important

Customer Data. Avoid logging full records, and don't use sample records as production defaults.

Compare With the Sample Invoice

Use the downloadable invoice to compare a known simple template with your application template.