RichEditMailMergeOptions.CustomSeparators Property
Allows you to specify group and decimal separators used in a numeric format switch.
Namespace: DevExpress.XtraRichEdit
Assembly: DevExpress.RichEdit.v24.1.Core.dll
NuGet Packages: DevExpress.RichEdit.Core, DevExpress.Win.Navigation
Declaration
Property Value
Type | Description |
---|---|
MailMergeCustomSeparators | An object that contains custom separator settings. |
Property Paths
You can access this nested property as listed below:
Object Type | Path to CustomSeparators |
---|---|
RichEditControlOptionsBase |
|
Remarks
When you use the RichEditDocumentServer library to open a template document with field codes that contain the decimal point and digit grouping symbol switches, the fields are parsed according to the current locale settings. Field codes and field results may change if the document template created on a machine with one local culture is opened on another locale.
You can use the RichEditMailMergeOptions.CustomSeparators
property to specify group and decimal separators that are independent of the current culture settings.
The code sample below shows how to specify custom decimal separators for the field code and field result. In the MERGEFIELD field, the decimal separator is retrieved from the current ES-ES locale (the “,” (comma) symbol) instead of the “.” (dot) symbol specified in the field code. As a result, the field result is changed - the field displays a whole number, and the dot is used as a thousands separator. The RichEditMailMergeOptions.CustomSeparators
options specify the dot as a decimal separator, which is displayed regardless of the culture settings.
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;
//...
var bindingSource = new BindingSource();
bindingSource.DataSource = new
{
Order = 10,
Amount = 12345.678m,
};
using (RichEditDocumentServer wordProcessor = new RichEditDocumentServer())
{
// Access a document.
Document document = wordProcessor.Document;
// Specify the data source of the document.
wordProcessor.Options.MailMerge.DataSource = bindingSource;
// Specify the custom decimal separator for the field code.
wordProcessor.Options.MailMerge.CustomSeparators.MaskDecimalSeparator = ".";
// Specify the custom decimal separator for the field result.
wordProcessor.Options.MailMerge.CustomSeparators.FieldResultDecimalSeparator = ".";
// Create the "MERGEFIELD" field.
document.Fields.Create(document.Range.Start, @"MERGEFIELD Amount \# 0.00 ");
// Merge the document.
wordProcessor.Document.MailMerge("output.docx", DocumentFormat.OpenXml);
}