Encrypting Excel Files in Aspose.Cells

Using Microsoft Excel

To set file encryption settings in Microsoft Excel (here Microsoft Excel 2003):

  1. From the Tools menu, select Options. A dialog appears.
  2. Select the Security tab.
  3. Input a password and click Advanced Options dialog


  1. Choose the encryption type and confirm the password.

    Encryption Type dialog


Encryption with Aspose.Cells

The following example shows how to encrypt and password protect an excel file using the Aspose.Cells API.


 //Instantiate a Workbook object.

//Open an excel file.

Workbook workbook = new Workbook("Book1.xls");

//Specify XOR encryption type.


//Specify Strong Encryption type (RC4,Microsoft Strong Cryptographic Provider).

workbook.SetEncryptionOptions(EncryptionType.StrongCryptographicProvider, 128);

//Password protect the file.

workbook.Settings.Password = "1234";

//Save the excel file.


Download Running Code

Download Sample Code