MailMerge 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.
is a powerful, extensible framework that allows you to inject custom logic to the merge process. The TXTextControl.DocumentServer.MailMerge.FieldMerged event TX Text Control .NET for Windows Forms
DocumentServer Namespace
MailMerge Class
FieldMerged Event
Occurs when a field has been merged.
can be used to manipulate the results, but also gives access to the surrounding instance of the TXTextControl.TableCell class TX Text Control .NET for Windows Forms
TXTextControl Namespace
TableCell Class
An instance of the TableCell class represents a single cell of a table in a Text Control document.
.

This enables you to implement features such as conditional table cell colors based on specific filter instructions.

In this sample, the table cell Qty should be highlighted red, if quantity is higher than 10, otherwise it should be green.

Conditional Cells

This sample shows two interesting aspects:

The sample implements HTML form elements to set the conditions for table cells. If the input position is inside a table cell, the following code is used to store the conditions in the table cell by serializing the object as a Json string:

Loading...

If the input position is changed to another cell, the form elements are updated to reflect the conditions of that cell:

Loading...

Finally, when clicking Merge, the document is saved and sent to the backend controller:

Loading...

In the controller, an HttpPost method accepts the document and calls the MergeJsonData TX Text Control .NET Server for ASP.NET
DocumentServer Namespace
MailMerge Class
MergeJsonData Method
Merges data given as a JSON string into a document template.
method to merge data into the given template:

Loading...

The FieldMerged TX Text Control .NET Server for ASP.NET
DocumentServer Namespace
MailMerge Class
FieldMerged Event
Occurs when a field has been merged.
event is attached to handle the custom condition. If the field is inside a table cell, the TableCell.Name TX Text Control .NET Server for ASP.NET
TXTextControl Namespace
TableCell Class
Name Property
Gets or sets the cell's name.
property is deserialized to a CellFilterInstructions object in order to apply the table cell color according to the defined instructions.

Loading...

Test this on your own by downloading the sample project from our GitHub repository.