Sneak Peek X16: Excel Formulas and MailMerge
With the release of TX Text Control X16, Excel compatible formulas can be used in table cells. This article shows how to utilize them within MailMerge templates.

In TX Text Control X16, Excel compatible formulas can be used in table cells to calculate results based on values and references to other cells in the same table. More than 100 different formulas are supported and can be combined.
This feature gets even more powerful when used in combination with TXText
The following screenshot shows a list of invoice items created with MailMerge:
The data for this example is a very simple XML:
<data>
<invoice>
<item>
<qty>1</qty>
<name>Road-650 Red, 44</name>
<unit_price>419.4589</unit_price>
<discount>0</discount>
</item>
<item>
<qty>5</qty>
<name>Road-450 Red, 52</name>
<unit_price>809.76</unit_price>
<discount>0</discount>
</item>
<item>
<qty>1</qty>
<name>HL Mountain Frame - Black, 38</name>
<unit_price>714.7043</unit_price>
<discount>12</discount>
</item>
<item>
<qty>2</qty>
<name>AWC Logo Cap</name>
<unit_price>5.1865</unit_price>
<discount>0</discount>
</item>
<item>
<qty>10</qty>
<name>Mountain-100 Black, 38</name>
<unit_price>2024.994</unit_price>
<discount>20</discount>
</item>
<item>
<qty>13</qty>
<name>Sport-100 Helmet, Blue</name>
<unit_price>20.1865</unit_price>
<discount>2</discount>
</item>
</invoice>
</data>
In the above XML source, you can see that only 4 data points are available:
- qty
- name
- unit_price
- discount
The other columns in the table are calculated based on these values.
The following screenshot shows the formula of the Line Total column in the ribbon UI. The value is calculated based on quantity multiplied the unit price minus discount.
The Total value is calculated with the following formula that creates a sum of all numeric rows above in the same column:
SUM(ABOVE)
Additionally, two values are calculated based on the existing data in the table.
- Average discount:
SUM(ABOVE)/COUNT(ABOVE) - Number of items:
COUNT(ABOVE)-1
In this sample template, another new feature of MailMerge is used: Sorting. The complete list is sorted by unit price:
This sample shows the power of MailMerge in combination with Microsoft Excel compatible formulas. The major advantage of using formulas is that data, that could be calculated, must not be stored in your data source or must not be calculated in your business object. TX Text Control is doing this for you when the data is required.
Another great idea of TX Text Control X16 - stay tuned for more.
Also See
This post references the following in the documentation:
- TXText
Control. Document Server. Mail Merge Class
Jump to the other posts in this series:
- Sneak Peek X16: Excel Formulas and MailMerge
- Sneak Peek X16: MS Word Compatible Track Changes
- Sneak Peek X16: Filter and Sort MergeBlock Rows
- Sneak Peek X16: New Customizable Sidebar Controls
- Sneak Peek X16: Working with Formulas in Table Cells
- Sneak Peek X16: Selecting Reference Cells for Table Formulas
Reporting
The Text Control Reporting Framework combines powerful reporting features with an easy-to-use, MS Word compatible word processor. Users can create documents and templates using ordinary Microsoft Word skills. The Reporting Framework is included in all .NET based TX Text Control products including ASP.NET, Windows Forms and WPF.
Related Posts
ReportingCloud: Backend Updated to TX Text Control X16
We just updated ReportingCloud to the latest version of TX Text Control X16 that comes with loads of new features that can be used in the reporting Web API now as well.
Automatically Format Numbers in Table Cells
The NumberFormat property can be used to automatically format numbers in table cells. This article shows how to use this feature.
Opening Microsoft Excel files with TX Text Control X16
Using TX Text Control X16, Excel spreadsheets can be imported into documents. This article shows several ways to work with Excel worksheets.
Loading and Processing Excel XLSX Spreadsheet Tables into TX Text Control…
TX Text Control provides a powerful API to load and process Excel spreadsheet tables in .NET applications. This article shows how to load an Excel file and process the tables using TX Text Control…
TX Text Control 32.0 Has Been Released
We are pleased to announce the immediate availability of TX Text Control 32.0 for all platforms including ASP.NET, Windows Forms, WPF and ActiveX.