.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

Workbook.SaveDocument(String, EncryptionSettings) Method

Saves the document to a file in the Excel or text format with the specified encryption settings. The file format is identified by the file extension.

You need an active license for the DevExpress Office File API Subscription or DevExpress Universal Subscription to use this method in production code.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Docs.v20.1.dll


public void SaveDocument(
    string fileName,
    EncryptionSettings encryptionSettings
Public Sub SaveDocument(
    fileName As String,
    encryptionSettings As EncryptionSettings


Name Type Description
fileName String

Specifies the file path to save the document.

encryptionSettings EncryptionSettings

Specifies encryption options.


The DocumentFormat enumeration lists the supported document formats. To export a file to PDF or HTML, use the Workbook.ExportToPdf and Workbook.ExportToHtml methods.

This SaveDocument method overload allows you to encrypt a workbook with a password, as shown below:

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

Workbook workbook = new Workbook();
// ...

// Specify encryption settings.
EncryptionSettings encryptionSettings = new EncryptionSettings();
encryptionSettings.Type = DevExpress.Spreadsheet.EncryptionType.Strong;
encryptionSettings.Password = "password";

// Save the document.
workbook.SaveDocument("Document.xlsx", encryptionSettings);
See Also