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

Workbook.LoadDocument(String) Method

Loads a document 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
)

Parameters

Name Type Description
fileName String

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

Returns

Type Description
Boolean

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

Remarks

When you use this method to load a document from a file, the Spreadsheet automatically identifies the document’s format based on its content (regardless of filename extension).

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 the loaded document.

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

The following code snippets (auto-collected from DevExpress Examples) contain references to the LoadDocument(String) 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