使用Node.js与C++保护和取消保护工作簿结构

在 MS Excel 中保护和取消保护工作簿结构

保护和取消保护工作簿结构

  1. 点击 审阅 > 保护工作簿
  2. 密码框 中输入密码。
  3. 选择 确定,重新输入密码以确认,然后再次选择 确定

** 使用Aspose.Cells for Node.js via C++保护工作簿结构**

只需要以下简单代码行来实现保护 Excel 文件的工作簿结构。

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");
// Create a new file.
const workbook = new AsposeCells.Workbook();
// Protect workbook structure.
workbook.protect(AsposeCells.ProtectionType.Structure, "password");
// Save Excel file.
workbook.save(filePath);

使用Aspose.Cells for Node.js via C++取消保护工作簿结构

使用 Aspose.Cells API 轻松取消工作簿结构保护。

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

// Open an Excel file which workbook structure is protected.
const workbook = new AsposeCells.Workbook(filePath);
// Unprotect workbook structure.
workbook.unprotect("password");
// Save Excel file.
workbook.save(filePath);