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

Workbook.LoadDocument(Byte[], DocumentFormat) Method

Loads a document in the specified format from a byte array.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Docs.v19.1.dll

Declaration

public bool LoadDocument(
    byte[] buffer,
    DocumentFormat format
)

Parameters

Name Type Description
buffer Byte[]

A byte array that contains document data.

format DocumentFormat

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

Returns

Type Description
Boolean

true, if the document was successfully loaded; 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 the loaded document.

You can use the current LoadDocument method overload to load a workbook stored in an external database. Refer to the How to: Store a Workbook in the Database document for more information.

// Add a reference to the DevExpress.Docs.dll assembly.
using DevExpress.Spreadsheet;
// ...

Workbook workbook = new Workbook();

// Save a document to a byte array to store it in a database.
byte[] docBytes = workbook.SaveDocument(DocumentFormat.Xlsx);

// ...

// Load the saved document from a byte array into the Workbook instance.
workbook.LoadDocument(docBytes, DocumentFormat.Xlsx);
See Also