How to: Save a Document to a File
- 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 save a spreadsheet document loaded to the Workbook object, use the Workbook.SaveDocument method.
Save to File
Call the Workbook.SaveDocument method with the passed 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); }