Skip to main content

SpreadsheetControl.LoadDocument(Stream, DocumentFormat) Method

Loads a document from a stream, specifying the document format.

Namespace: DevExpress.XtraSpreadsheet

Assembly: DevExpress.XtraSpreadsheet.v24.1.dll

NuGet Package: DevExpress.Win.Spreadsheet

Declaration

public bool LoadDocument(
    Stream stream,
    DocumentFormat format
)

Parameters

Name Type Description
stream Stream

The stream from which to load a document.

format DocumentFormat

One of the DocumentFormat members.

Returns

Type Description
Boolean

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

Remarks

The IWorkbook interface provides the equivalent method.

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