Node.js経由のC++を使ったワークシートの保護・解除

MS Excelでのワークシートの保護と保護解除

ワークシートの保護と保護解除

  1. レビュー > ワークシートの保護 をクリックします。
  2. パスワードボックス にパスワードを入力します。
  3. 許可 オプションを選択します。
  4. OK を選択し、パスワードを再入力して確認し、その後再度 OK を選択します。

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");
// Create a new file.
const workbook = new AsposeCells.Workbook();
// Gets the first worksheet.
const sheet = workbook.getWorksheets().get(0);
// Protect contents of the worksheet.
sheet.protect(AsposeCells.ProtectionType.Contents);
// Protect worksheet with password.
sheet.getProtection().setPassword("test");
// Save as Excel file.
workbook.save("Book1.xlsx");

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");
// Create a new file.
const workbook = new AsposeCells.Workbook(filePath);
// Gets the first worksheet.
const sheet = workbook.getWorksheets().get(0);
// Protect contents of the worksheet.
sheet.unprotect("password");
// Save Excel file.
workbook.save("Book1.xlsx");

高度なトピック