DocxFormatProvider allows for import of DOCX documents and respectively export of RadDocument to DOCX. Additionally, the export settings provide modification options. The current article outlines the available settings.
DocxFormatProvider exposes ExportSettings, which allow customization in how fields are exported. By default, all fields are exported using their result value in the docx document. If you would like to save the document of the editor as a mail merge template and not include the value of the current item of the MailMergeDataSource, a new instance of DocxExportSettings should be created and assigned to the format provider. The value of the FieldResultMode of these settings must be set to FieldDisplayMode.DisplayName.
Example 1 shows you how you can get a reference to the format provider used by the OpenDocumentCommand and the SaveCommand and adjust the export, so that the document is saved as a template:
Example 1: Setup default DocxFormatProvider
public void SetupDefaultDocxFormatProvider()
//Obtain a reference to the format provider used by the default UI - RadRichTextBoxRibbonUI
DocxFormatProvider docxFormatProvider = DocumentFormatProvidersManager.GetProviderByExtension("docx") as DocxFormatProvider;
DocxExportSettings docxExportSettings = new DocxExportSettings();
docxExportSettings.FieldResultMode = FieldDisplayMode.DisplayName;
docxFormatProvider.ExportSettings = docxExportSettings;
The FieldResultMode property of the DocxExportSettings is an enumeration and it allows the following values:
- Code: Shows all fields codes in the current document.
- DisplayName: Shows all fields names in the current document.
- Result: Replaces the merge fields in your document with actual data from your recipient list.
Null: When the FieldResultMode is set to
null, fields' display mode is not changed. This can provide a better performance and lower memory usage while exporting.