Workbook.LoadDocument(String, DocumentFormat) Method
Loads a document from a file, specifying the document format.
You require a license to the DevExpress Office File API or DevExpress Universal Subscription to use this method in production code.
Namespace: DevExpress.Spreadsheet
Assembly: DevExpress.Docs.v18.2.dll
Declaration
Parameters
Name | Type | Description |
---|---|---|
fileName | String | A string specifying the file to load (including the full path). |
format | DocumentFormat | One of the DocumentFormat members. |
Returns
Type | Description |
---|---|
Boolean | true, if a document is loaded successfully; otherwise, false. |
Remarks
If the data you are trying to load has an incorrect format, the Workbook.InvalidFormatException event fires. You can subscribe to this event and perform required actions to resolve this situation. To throw an exception on loading an invalid document, set the WorkbookImportOptions.ThrowExceptionOnInvalidDocument property to true (import options are accessible via the Workbook.Options.Import notation).
To determine the moment you can safely modify a loaded document, handle the Workbook.DocumentLoaded event.
Example
// Add a reference to the DevExpress.Docs.dll assembly.
using DevExpress.Spreadsheet;
// ...
Workbook workbook = new Workbook();
// Load a workbook from the file.
workbook.LoadDocument("Documents\\Document.xlsx", DocumentFormat.Xlsx);
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the LoadDocument(String, DocumentFormat) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.