设置强加密类型

使用 Microsoft Excel 应用加密

在Microsoft Excel(以2007为例)中实现文件加密:

  1. 来自工具菜单,选择选项.
  2. 选择安全标签。
  3. 输入一个值打开密码场地。
  4. 点击先进的.
  5. 选择加密类型并确认密码。

使用 Aspose.Cells 应用加密

下面的代码示例对文件应用强加密并设置密码。

// 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");