Document Loading

  • 3 minutes to read

To start working with DevExpress office controls and use their extended document editing capabilities, load a document into the control. A document can be loaded into an office control in one of the following ways.

  • By default, a control is initialized with the automatically generated document (if no document is opened explicitly by code).
  • A new document can be created explicitly in one of the following ways:

    • Use the New command in the application's ribbon UI.
    • Use the New method (at the control level) to create a public API.
  • You can open an existing document via one of the approaches below:

    • Use the Open command in the application's ribbon UI.
    • Use the Open method (at the control level) to create a public API.

UI Commands

To load a document, end users can use the built-in ribbon’s New or Open commands (displayed in an office control by default).

Document Management UI

Ribbon commands (New, Open, Save and Save As) are available in the document management UI because the control uses the server's local file system for document storage. The server also defines an office control's WorkDirectory property - which specifies the server's root folder for all document operations (e.g., to open or save a file). The result is that all built-in File Dialogs are available to end users by default. Users can navigate through files and folders within the specified folder, and select documents to load or save.

If you use a custom document storage that is not based on the server file system (e.g., a database), hide the built-in ribbon's File tab and implement a custom UI for opening and saving documents. Note that the WorkDirectory and built-in document management ribbon commands are not in effect in this case.

API

The public API used to create and open documents is exposed at the level of the office control. The main API members are listed below.

Office Control Level

  • New method

    Creates a new empty document within an office control.

    Note that DocumentId is empty for a new document, so it cannot be accessed from a list of open documents maintained by DocumentManager. You need to specify a unique DocumentId for the newly created document, or else it is completely lost when an end user switches to another document (e.g., when a user creates another document or opens an existing document).

  • Open method overloads

    An office control opens a document specified by the method's parameters.

    Note that certain Open methods (which open a document from the server's file system) set the document's DocumentId automatically; other methods require you to specify it manually.

Refer to the following topics to learn more on how to open documents within DevExpress office controls.