使用Node.js通过C++设置强加密类型

在 Microsoft Excel 中应用加密

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

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

使用 Aspose.Cells 应用加密

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

const path = require("path");
const AsposeCells = require("aspose.cells.node");

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "Book1.xlsx");

// Instantiate a Workbook object.
// Open an excel file.
const workbook = new AsposeCells.Workbook(filePath);

// Specify Strong Encryption type (RC4,Microsoft Strong Cryptographic Provider).
workbook.setEncryptionOptions(AsposeCells.EncryptionType.StrongCryptographicProvider, 128);

// Password protect the file.
workbook.getSettings().setPassword("1234");

// Save the Excel file.
workbook.save(path.join(dataDir, "encryptedBook1.out.xls"));