How to: Save a Document to a File
- 2 minutes to read
Important
The Workbook class is defined in the DevExpress.Docs.v19.1.dll assembly. Add this assembly to your project to use the workbook functionality. You require a license to the DevExpress Office File API or DevExpress Universal Subscription to use this assembly in production code. Refer to the DevExpress Subscription page for pricing information.
To save a spreadsheet document loaded to the Workbook object, use the Workbook.SaveDocument method.
Save to File
Call the Workbook.SaveDocument method with the specified file path to save a workbook to the file. Specify the file format as the second parameter of the method using the DocumentFormat enumerator.
Save to Stream
Create the FileStream object with the specified file path to save a workbook, and call the Workbook.SaveDocument method with this stream 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(); // ... // Save the modified document to the stream. using (FileStream stream = new FileStream("Documents\\SavedDocument.xlsx", FileMode.Create, FileAccess.ReadWrite)) { workbook.SaveDocument(stream, DocumentFormat.Xlsx); }