IncludeText fields can be used to merge external references into a mail merge template using the reporting engine TXTextControl.DocumentServer.MailMerge class TX Text Control .NET for Windows Forms
DocumentServer Namespace
MailMerge Class
The MailMerge class is a .NET component that can be used to effortlessly merge template documents with database content in .NET projects, such as ASP.NET web applications, web services or Windows services.
. External documents of type DOC, DOCX, RTF and TX can be referenced and are automatically included during the merge process.

The TXTextControl.DocumentServer.MailMerge.IncludeTextMerging event TX Text Control .NET for Windows Forms
DocumentServer Namespace
MailMerge Class
IncludeTextMerging Event
Occurs when an IncludeText field has been merged.
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:

private void MailMerge_IncludeTextMerging(object sender,
TXTextControl.DocumentServer.MailMerge.IncludeTextMergingEventArgs e)
// custom handing of XLSX files
switch (Path.GetExtension(e.IncludeTextField.Filename))
case ".xlsx": // Excel file detected
if (!File.Exists(e.IncludeTextField.Filename))
// load document into temp. ServerTextControl
using (TXTextControl.ServerTextControl tx =
new TXTextControl.ServerTextControl())
// Bookmark name is the sheet name of the Excel document
TXTextControl.LoadSettings ls = new TXTextControl.LoadSettings()
DocumentPartName = e.IncludeTextField.Bookmark
// load the Excel document
catch {
byte[] data;
// save the document using the TX format
tx.Save(out data,
e.IncludeTextDocument = data; // pass back to the field
view raw data.cs hosted with ❤ by GitHub

In case the reference ends with .xlsx, the file is loaded into a temporary TXTextControl.ServerTextControl class TX Text Control .NET for Windows Forms
TXTextControl Namespace
ServerTextControl Class
The ServerTextControl class implements a component that provide high-level text processing features for server-based applications.
. 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 TX Text Control .NET for Windows Forms
DocumentServer Namespace
MailMerge.IncludeTextMergingEventArgs Class
IncludeTextDocument Property
Sets a byte[] array that contains the complete data of the IncludeText document.

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.