[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
 [Expand]What's Installed
 [Expand].NET Core 3 Support
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Collapse]Rich Text Editor
   [Expand]Product Information
    Product Class Structure
    Supported Formats
   [Expand]Getting Started
   [Expand]RichEditControl Document
    Text Formatting
    Import and Export
   [Expand]Page Layout
    Track Changes
    Mail Merge
    Restrictions and Protection
   [Expand]Visual Elements
    HTML Tag Support
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Import and Export

This document describes how to load and save documents in different formats. It consists of the following sections:

Expanded Built-in UI

End users can click the Open button on the File ribbon tab to invoke the Open dialog. Select the file you want to open and click Open.

The Save and Save As buttons on the File ribbon tab allow users to save the changes made to the current document or save it as a new file. Click the Save As button to invoke the Save As dialog used to save a copy as a new file, specify the document's location, name, and format. Refer to the Lesson 1 - Create a Simple Rich Text Editor for details on how to provide a ribbon UI for the RichEditControl.

The DXRichEditDocumentSaveOptions.CurrentFileName property returns the current document's file name (including the path and extension).


You can prohibit end-users from creating, loading or saving documents. Set the DXRichEditBehaviorOptions.CreateNew or DXRichEditBehaviorOptions.Open, DXRichEditBehaviorOptions.Save or DXRichEditBehaviorOptions.SaveAs property to DocumentCapability.Disabled to disable or hide the corresponding commands in the Ribbon UI and pop-up menu.

Expanded Initiate Load and Save Operations in Code


Use the RichEditControl.DocumentSource property to bind the RichEditControl to a document source from XAML. The following data sources are supported:

  • System.IO.Stream;
  • System.Uri;
  • System.String (document content or document path);
  • System.IO.FileInfo;
  • System.Byte[];
  • RichEditDocumentSource.

You can use the DXBinding extension to call a method that returns a valid document source directly in XAML, as in the following code:

Changes made in the bound document are not saved automatically. Refer to the Lesson 7 - Bind the RichEditControl to a Document Source using the MVVM pattern topic for information on how to implement a custom command to save changes to the database.


Execute one of the following commands to load or save a document:


The RichEditControl provides the following methods to load or save the document and specify its options. Refer to the Files examples section for code samples.

Member Description
RichEditControl.LoadDocument Loads a document from a file or stream. The document format can be specified by one of the DocumentFormat enumeration values or detected automatically.
RichEditControl.LoadDocumentTemplate Loads a document template from the specified file or stream so that it cannot be overwritten automatically.
Document.LoadDocument Loads a document from the specified file or stream. Its content can be specified by one of the DocumentFormat enumeration values or is automatically determined based on the file's format.
SubDocument.InsertDocumentContent Inserts content from the selected range into the current document at the specified position.
SubDocument.AppendDocumentContent Appends content from the selected range.
RichEditControl.SaveDocument Saves the control's document to a file or stream and specifies the document's format.
RichEditControl.SaveDocumentAs Invokes the Save As dialog and saves the document.
Document.SaveDocument Saves the document to a file or stream and specifies the document's format.

The SaveDocumentCommand or SaveDocumentAsCommand execution sets the RichEditControl.Modified property to false. The RichEditControl.SaveDocument, RichEditControl.SaveDocumentAs or Document.SaveDocument method call does not automatically change the Modified property value.

Expanded How to: Load and Save a Document

The code sample below loads the document from a file stream when the form is opened and saves the result to the file when the form is closed. Refer to the How to: Load a Document and How to: Save a Document examples for more code samples.

Expanded Basic Format-Specific API

Expanded How to: Handle BeforeImport and BeforeExport events


Check Export and Files examples section for more information on how to accomplish an import- or export-related task.

How to: Handle the BeforeImport Event

The code sample below illustrates how to handle RichEditControl.BeforeImport event for different document formats:

How to: Handle the BeforeExport Event

The code sample below shows how specify export options for different formats in the RichEditControl.BeforeExport event handler.

Expanded Notes on Document Content

Control Document Elements on Load

Use the RichEditControl.DocumentCapabilitiesOptions property to access the DXRichEditDocumentCapabilitiesOptions properties to control what document elements to import. Specify the options in the RichEditControl.BeforeImport event handler, as shown below. The restricted elements are lost when the document is saved.

HTML Tag Support

The RichEditControl parses and transforms loaded HTML documents into the internal document model. However, not every HTML tag can be converted into a corresponding document model element. Refer to the HTML Tag Support topic for a list of supported tags.

Expanded See Also

Is this topic helpful?​​​​​​​