SpreadsheetControl.LoadDocument(String) Method

Loads a document from a file.

Namespace: DevExpress.XtraSpreadsheet

Assembly: DevExpress.XtraSpreadsheet.v21.2.dll


public bool LoadDocument(
    string fileName


Name Type Description
fileName String

A string specifying the file to load (including the full path).


Type Description

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


The IWorkbook interface provides the equivalent method.

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

If the data you are trying to load has an incorrect format, the SpreadsheetControl.InvalidFormatException event fires. You can subscribe to this event and perform required actions to resolve this situation (for example, inform an end-user about the incorrect file). To throw an exception on loading an invalid document, set the WorkbookImportOptions.ThrowExceptionOnInvalidDocument property to true (import options are accessible via the SpreadsheetControl.Options.Import notation).

To determine the moment you can safely modify a loaded document, handle the SpreadsheetControl.DocumentLoaded event.

See Also