Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+
Row

Workbook.LoadDocument(String, DocumentFormat) Method

Loads a document in the specified format from a file.

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.v19.1.dll

Declaration

public bool LoadDocument(
    string fileName,
    DocumentFormat format
)

Parameters

Name Type Description
fileName String

A string that specifies a file to load (including the full path).

format DocumentFormat

A DocumentFormat enumeration member that specifies the format of the loaded document.

Returns

Type Description
Boolean

true, if a document was loaded successfully; otherwise, false.

Remarks

If you attempt to load a document in an incorrect format, the Workbook.InvalidFormatException event fires. To throw an exception when an invalid document is loaded, set the WorkbookImportOptions.ThrowExceptionOnInvalidDocument property to true (use the Workbook.Options.Import notation to access import options).

Handle the Workbook.DocumentLoaded event to determine when you can safely modify a loaded document.

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

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.

See Also