# MailMerge: Formatting Numeric Strings in Merge Fields

> MergeFields in TX Text Control support numeric and date formatting through standard and custom format specifiers. Standard formats like C2 produce currency output, while custom specifiers such as zero placeholders and digit placeholders control decimal display within the template.

- **Author:** Bjoern Meyer
- **Published:** 2015-01-22
- **Modified:** 2026-07-17
- **Description:** MergeFields in TX Text Control support numeric and date formatting through standard and custom format specifiers. Standard formats like C2 produce currency output, while custom specifiers such as zero placeholders and digit placeholders control decimal display within the template.
- **4 min read** (683 words)
- **Tags:**
  - Reporting
  - Tutorial
- **Web URL:** https://www.textcontrol.com/blog/2015/01/22/mailmerge-formatting-numeric-strings-in-merge-fields/
- **LLMs URL:** https://www.textcontrol.com/blog/2015/01/22/mailmerge-formatting-numeric-strings-in-merge-fields/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2015/01/22/mailmerge-formatting-numeric-strings-in-merge-fields/llms-full.txt

---

MergeFields are very powerful elements and provide many different options such as additional text that should be added in front or after the field text and a pre-defined format such as *UPPERCASE* or *Title Case*.

But the most powerful feature is the string formatter for numeric numbers and date values.

A typical sample for a numeric format is a currency. The merge field value comes from a data source and contains a simple Integer and Float value such as the number *24*. But the field should render the value with a currency symbol and 2 decimal digits: *$24.00*.

In this case, the *numeric format* of the field can be used to render the required format:

![MailMerge: Formatting strings in merge fields](https://s1-www.textcontrol.com/assets/dist/blog/2015/01/22/a/assets/format_dialog.webp "MailMerge: Formatting strings in merge fields")

Text Control's reporting engine MailMerge supports all standard numeric formats, custom numeric formats and standard and custom date and time formats.

The above sample shows a custom numeric string format. In order to add a currency symbol and 2 decimal digits, the following formats can be used:

```
$##,###.00
```

```
C2
```

Results:

```
2400 -> $2,400.00
```

The first is a custom format with various format specifiers such as *zero placeholdes*, *digit placeholders* and *decimal points*.

The second is a standard numeric format for currencies with 2 decimal digits. The following table lists the standard numeric formats with examples (from [MSDN](https://msdn.microsoft.com/en-us/library/dwhawy9k%28v=vs.110%29.aspx)):

| Format specifier | Name | Description | Examples |
|---|---|---|---|
| "C" or "c" | Currency | Result: A currency value.   Supported by: All numeric types.   Precision specifier: Number of decimal digits. | 123.456 ("C") -> $123.46 |
| "D" or "d" | Decimal | Result: Integer digits with optional negative sign.   Supported by: Integral types only.   Precision specifier: Minimum number of digits. | -1234 ("D6") -> -001234 |
| "E" or "e" | Exponential | Result: Exponential notation.   Supported by: All numeric types.   Precision specifier: Number of decimal digits. | 1052.0329112756 ("E") -> 1.052033E+003 |
| "F" or "f" | Fixed-point | Result: Integral and decimal digits with optional negative sign.   Supported by: All numeric types.   Precision specifier: Number of decimal digits. | 1234 ("F1") -> 1234.0 |
| "G" or "g" | General | Result: The most compact of either fixed-point or scientific notation.   Supported by: All numeric types.   Precision specifier: Number of significant digits. | 123.4546 ("G4") -> 123.5 |
| "P" or "p" | Percent | Result: Number multiplied by 100 and displayed with a percent symbol.   Supported by: All numeric types.   Precision specifier: Desired number of decimal places. | 1 ("P") -> 100,00 % |
| "R" or "r" | Round-trip | Result: A string that can round-trip to an identical number.   Supported by: Single, Double, and BigInteger.   Precision specifier: Ignored. | -1234567890.12345678 ("R") -> -1234567890.1234567 |

The next table lists the custom numeric format specifiers and shows samples produced by each format specifier:

| Format specifier | Name | Description | Examples |
|---|---|---|---|
| "0" | Zero placeholder | Replaces the zero with the corresponding digit if one is present; otherwise, zero appears in the result string. | 1234.5678 ("00000") -> 01235 |
| "#" | Digit placeholder | Replaces the "#" symbol with the corresponding digit if one is present; otherwise, no digit appears in the result string. | 0.45678 ("#.##") -> .46 |
| "." | Decimal point | Determines the location of the decimal separator in the result string. | 0.45678 ("0.00") -> 0.46 |
| "," | Group separator and number scaling | Serves as both a group separator and a number scaling specifier. As a group separator, it inserts a localized group separator character between each group. As a number scaling specifier, it divides a number by 1000 for each comma specified. | 2147483647 ("##,#") -> 2,147,483,647 |
| "%" | Percentage placeholder | Multiplies a number by 100 and inserts a localized percentage symbol in the result string. | 0.3697 ("%#0.00") -> %36.97 |
| "‰" | Per mille placeholder | Multiplies a number by 1000 and inserts a localized per mille symbol in the result string. | 0.03697 ("#0.00‰") -> 36.97‰ |
| \\ | Escape character | Causes the next character to be interpreted as a literal rather than as a custom format specifier. | 987654 ("\\###00\\#") -> #987654# |
| 'string' or "string" | Literal string delimiter | Indicates that the enclosed characters should be copied to the result string unchanged. | 68 ("# ' degrees'") -> 68 degrees |
| ; | Section separator | Defines sections with separate format strings for positive, negative, and zero numbers. | 12.345 ("#0.0#;(#0.0#);-\\0-") -> 12.35 |

In order to keep clean data in database tables, the formatting of numeric strings should be part of the template. The string formatter provides a powerful way to format numeric strings or date values.

---

## About Bjoern Meyer

As CEO, Bjoern is the visionary behind our strategic direction and business development, bridging the gap between our customers and engineering teams. His deep passion for coding and web technologies drives the creation of innovative products. If you're at a tech conference, be sure to stop by our booth - you'll most likely meet Bjoern in person. With an advanced graduate degree (Dipl. Inf.) in Computer Science, specializing in AI, from the University of Bremen, Bjoern brings significant expertise to his role. In his spare time, Bjoern enjoys running, paragliding, mountain biking, and playing the piano.

- [LinkedIn](https://www.linkedin.com/in/bjoernmeyer/)
- [X](https://x.com/txbjoern)
- [GitHub](https://github.com/bjoerntx)

---

## Related Posts

- [Creating Your First ASP.NET Reporting Application](https://www.textcontrol.com/blog/2020/01/01/creating-your-first-aspnet-reporting-application/llms.txt)
- [New Online Sample: Build your First Report](https://www.textcontrol.com/blog/2019/07/03/build-your-first-report/llms.txt)
- [Create your First Document with ReportingCloud](https://www.textcontrol.com/blog/2019/02/19/create-your-first-document-with-reportingcloud/llms.txt)
- [MailMerge: Starting Each Merge Block on a New Page](https://www.textcontrol.com/blog/2016/09/09/mailmerge-starting-each-merge-block-on-a-new-page/llms.txt)
- [Using MailMerge with JSON Data](https://www.textcontrol.com/blog/2015/08/04/using-mailmerge-with-json-data/llms.txt)
- [Merging Documents with RESTful Web API's](https://www.textcontrol.com/blog/2015/07/31/merging-documents-with-restful-web-apis/llms.txt)
- [Windows Forms: Printing Multiple Pages Per Sheet](https://www.textcontrol.com/blog/2015/07/24/windows-forms-printing-multiple-pages-per-sheet/llms.txt)
- [Inserting Watermark Images to All Pages Dynamically](https://www.textcontrol.com/blog/2015/07/17/inserting-watermark-images-to-all-pages-dynamically/llms.txt)
- [Reporting: Sorting Merge Block Rows by Column Name](https://www.textcontrol.com/blog/2015/07/15/reporting-sorting-merge-block-rows-by-column-name/llms.txt)
- [MailMerge with the Entity Framework Using Database First](https://www.textcontrol.com/blog/2015/06/24/mailmerge-with-the-entity-framework-using-database-first/llms.txt)
- [Checked and Unchecked Check Boxes with IF Fields](https://www.textcontrol.com/blog/2015/03/25/checked-and-unchecked-check-boxes-with-if-fields/llms.txt)
- [Reporting: Conditional Formatted Text Blocks](https://www.textcontrol.com/blog/2015/03/13/reporting-conditional-formatted-text-blocks/llms.txt)
- [Reporting Best Practices and How-To Guides](https://www.textcontrol.com/blog/2015/02/05/reporting-best-practices-and-how-to-guides/llms.txt)
- [MailMerge: Master Table and Client Tables](https://www.textcontrol.com/blog/2015/01/28/mailmerge-master-table-and-client-tables/llms.txt)
- [MailMerge: Merge CheckBoxes During the Merge Process](https://www.textcontrol.com/blog/2015/01/12/mailmerge-merge-checkboxes-during-the-merge-process/llms.txt)
- [MailMerge: Conditional INCLUDETEXT Fields](https://www.textcontrol.com/blog/2015/01/08/mailmerge-conditional-includetext-fields/llms.txt)
- [HTML5 Technical Considerations - The Concept Explained](https://www.textcontrol.com/blog/2014/10/16/html5-technical-considerations-the-concept-explained/llms.txt)
- [TX Text Control Web: Attaching Events to Ribbon Elements](https://www.textcontrol.com/blog/2014/10/07/tx-text-control-web-attaching-events-to-ribbon-elements/llms.txt)
- [TX Text Control Web: Customize the Ribbon Bar](https://www.textcontrol.com/blog/2014/10/03/tx-text-control-web-customize-the-ribbon-bar/llms.txt)
- [Text Control Web - Fundamental Concepts: The Data Source](https://www.textcontrol.com/blog/2014/10/02/text-control-web-fundamental-concepts-the-data-source/llms.txt)
- [Reporting: Removing Empty Table Rows](https://www.textcontrol.com/blog/2014/09/30/reporting-removing-empty-table-rows/llms.txt)
- [MS Word Content Controls Field Adapter Classes](https://www.textcontrol.com/blog/2014/08/05/ms-word-content-controls-field-adapter-classes/llms.txt)
- [Reporting: Merge Blocks and Structured Numbered Lists](https://www.textcontrol.com/blog/2014/07/29/reporting-merge-blocks-and-structured-numbered-lists/llms.txt)
- [Creating Avery Labels Using Text Control Reporting](https://www.textcontrol.com/blog/2014/07/22/creating-avery-labels-using-text-control-reporting/llms.txt)
- [New Online Samples for TX Text Control .NET Server](https://www.textcontrol.com/blog/2014/07/16/new-online-samples-for-tx-text-control-net-server-for-aspnet/llms.txt)
