Verifiera lösenordet som användes för att skydda kalkbladet med Node.js via C++

Contents
[ ]

Metoden Protection.verifyPassword(string) returnerar true om det angivna lösenordet matchar lösenordet som användes för att skydda kalkbladet och false om det inte matchar. Följande kod använder Protection.verifyPassword(string) i samband med Protection.isProtectedWithPassword()-egenskapen för att upptäcka lösenordsskyddet och verifiera lösenordet.

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

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "Sample.xlsx");
// Create an instance of Workbook and load a spreadsheet
const workbook = new AsposeCells.Workbook(filePath);

// Access the protected Worksheet
const sheet = workbook.getWorksheets().get(0);

// Check if Worksheet is password protected
if (sheet.getProtection().isProtectedWithPassword()) {
// Verify the password used to protect the Worksheet
if (sheet.getProtection().verifyPassword("1234")) {
console.log("Specified password has matched");
} else {
console.log("Specified password has not matched");
}
}