IXlExporter.CreateDocument(Stream, EncryptionOptions) Method

Creates a password-protected document using the specified encryption options.

Namespace: DevExpress.Export.Xl

Assembly: DevExpress.Printing.v21.2.Core.dll

Declaration

IXlDocument CreateDocument(
    Stream stream,
    EncryptionOptions encryptionOptions
)

Parameters

Name Type Description
stream Stream

The System.IO.Stream object to output the document to.

encryptionOptions EncryptionOptions

An EncryptionOptions object containing encryption settings.

Returns

Type Description
IXlDocument

An IXlDocument object that is the newly created encrypted workbook.

Example

// Create an exporter instance.
IXlExporter exporter = XlExport.CreateExporter(documentFormat);

// Specify encryption options. 
// A workbook will be encrypted using the default encryption mechanism
// (agile encryption for XLSX files, and RC4 encryption for XLS files).
EncryptionOptions encryptionOptions = new EncryptionOptions();
// Specify the encryption password.
encryptionOptions.Password = "password";

// Create a new document and encrypt its contents.
using (IXlDocument document = exporter.CreateDocument(stream, encryptionOptions))
{
    // Specify the document culture. 
    document.Options.Culture = CultureInfo.CurrentCulture;
}
See Also