Skip to main content

MailMergeCustomSeparators Class

Contains custom separators used in numeric format switches of the document fields.

Namespace: DevExpress.XtraRichEdit

Assembly: DevExpress.RichEdit.v24.1.Core.dll

NuGet Packages: DevExpress.RichEdit.Core, DevExpress.Win.Navigation

Declaration

[ComVisible(true)]
[TypeConverter(typeof(ExpandableObjectConverter))]
public class MailMergeCustomSeparators

The following members return MailMergeCustomSeparators objects:

Library Related API Members
WPF Controls DXRichEditMailMergeOptions.CustomSeparators
Office File API RichEditMailMergeOptions.CustomSeparators

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.

Specify Custom Decimal Separators

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);
}

Inheritance

Object
MailMergeCustomSeparators
See Also