Setting Strong Encryption Type

Applying Encryption with Microsoft Excel

To implement file encryption in Microsoft Excel (for example 2007):

  1. From the Tools menu, select Options.
  2. Select the Security tab.
  3. Enter a value for the Password to open field.
  4. Click Advanced.
  5. Choose the encryption type and confirm the password.

Applying Encryption with Aspose.Cells

The code examples below apply strong encryption on a file and set a password.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Instantiate a Workbook object.
// Open an excel file.
Workbook workbook = new Workbook(dataDir+ "Book1.xlsx");
// 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.
workbook.Save(dataDir+ "encryptedBook1.out.xls");