Aspose.Cells for Node.js via C++を使用した修正パスワードの確認

Microsoft Excelで変更するためのパスワードをチェックする

Microsoft Excelで作成するワークブックに開くためのパスワードおよび変更するためのパスワードを割り当てることができます。これらのパスワードを指定するためのMicrosoft Excelが提供するインターフェースを示すスクリーンショットをご覧ください。

todo:image_alt_text

Aspose.Cells for Node.js via C++を使用した修正パスワードの確認例

以下のサンプルコードは、ソースExcelファイルを読み込みます。このファイルには、開くためのパスワードが1234、修正用パスワードが5678と設定されています。最初に、567が正しい修正パスワードかどうかを確認し、間違っていればfalseを返します。次に、5678が正しい修正パスワードかどうかをチェックし、正しければtrueを返します。

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

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

// Specify password to open inside the load options
const opts = new AsposeCells.LoadOptions();
opts.setPassword("1234");

// Open the source Excel file with load options
const workbook = new AsposeCells.Workbook(path.join(dataDir, "sampleBook.xlsx"), opts);

// Check if 567 is Password to modify
let ret = workbook.getSettings().getWriteProtection().validatePassword("567");
console.log("Is 567 correct Password to modify: " + ret);

// Check if 5678 is Password to modify
ret = workbook.getSettings().getWriteProtection().validatePassword("5678");
console.log("Is 5678 correct Password to modify: " + ret);

コンソール出力

上記のサンプルコードで元のExcelファイルをロードした後のコンソール出力はこちらです。

  
Is 567 correct Password to modify: False  
Is 5678 correct Password to modify: True