IncludeText fields can be used to merge external references into a mail merge template using the reporting engine TXTextControl.DocumentServer.MailMerge. External documents of type DOC, DOCX, RTF and TX can be referenced and are automatically included during the merge process.

The event TXTextControl.DocumentServer.MailMerge.IncludeTextMerging can be used to inject other files or formatted text by returning a document in the event. The following code shows how to handle Excel file references:


In case the reference ends with .xlsx, the file is loaded into a temporary TXTextControl.ServerTextControl. The Bookmark property of the IncludeTextField is used to define the sheet name in the Excel document. After the document is loaded successfully into ServerTextControl, it is exported in the internal TX Text Control format and returned to the TXTextControl.DocumentServer.MailMerge.IncludeTextMergingEventArgs.IncludeTextDocument property.

The following screen video shows this in action:

Screen video merge Excel

Download this sample from our GitHub repository and try this on your own.


Download and Fork This Sample on GitHub

We proudly host our sample code on

Please fork and contribute.

Requirements for This Sample

  • Visual Studio 2017 or better
  • TX Text Control .NET for Windows Forms X17 (trial sufficient)