Skip to main content
A newer version of this page is available. .

IXlExporter.CreateDocument(Stream, EncryptionOptions) Method

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

Namespace: DevExpress.Export.Xl

Assembly: DevExpress.Printing.v18.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

Note

A complete sample project is available at https://github.com/DevExpress-Examples/xl-export-api-examples-t253492

// 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;
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CreateDocument(Stream, EncryptionOptions) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also