How to: Load a Document to a Workbook
- 2 minutes to read
Important
The Workbook class in defined in the DevExpress.Docs.v17.2.dll assembly. Make sure you added a reference for this library to your project before using the workbook functionality. Note that use of this library in production code requires a license to the DevExpress Document Server or DevExpress Universal Subscription. Refer to the DevExpress Subscription page for pricing information.
To load an existing spreadsheet document into the Workbook object, use the Workbook.LoadDocument method.
Load from File
Create a new Workbook object and call the Workbook.LoadDocument method with the passed file path to load a workbook from the existing file. Specify the file format as the second parameter of the method using the DocumentFormat enumerator.
Load from Stream
Create the FileStream object with the specified file path to open the existing file, and call the Workbook.LoadDocument method with this stream object passed as a parameter. Specify the file format as the second parameter of the method using the DocumentFormat enumerator.
// Add a reference to the DevExpress.Docs.dll assembly. using DevExpress.Spreadsheet; using System.IO; // ... Workbook workbook = new Workbook(); // Load a workbook from the stream. using (FileStream stream = new FileStream("Documents\\Document.xlsx", FileMode.Open)) { workbook.LoadDocument(stream, DocumentFormat.Xlsx); }