设置强加密类型

在 Microsoft Excel 中应用加密

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

  1. 从** 工具** 菜单中选择 **选项**。
  2. 选择安全选项卡。
  3. 打开密码字段输入一个值。
  4. 点击“高级”。
  5. 选择加密类型并确认密码。

使用 Aspose.Cells 应用加密

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

from aspose.cells import EncryptionType, Workbook
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# The path to the documents directory.
dataDir = RunExamples.GetDataDir(".")
# Instantiate a Workbook object.
# Open an excel file.
workbook = Workbook(dataDir + "Book1.xlsx")
# Specify Strong Encryption type (RC4,Microsoft Strong Cryptographic Provider).
workbook.set_encryption_options(EncryptionType.STRONG_CRYPTOGRAPHIC_PROVIDER, 128)
# Password protect the file.
workbook.settings.password = "1234"
# Save the Excel file.
workbook.save(dataDir + "encryptedBook1.out.xls")