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:

Loading...

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.

GitHub

Download and Fork This Sample on GitHub

We proudly host our sample code on github.com/TextControl.

Please fork and contribute.

Requirements for This Sample

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