Verifica la password usata per proteggere il foglio di lavoro con Node.js tramite C++

Contents
[ ]

Il metodo Protection.verifyPassword(string) restituisce true se la password specificata corrisponde a quella usata per proteggere il foglio di lavoro dato e false se la password specificata non corrisponde. Il seguente esempio di codice utilizza il metodo Protection.verifyPassword(string) in combinazione con la proprietà Protection.isProtectedWithPassword() per rilevare la protezione tramite password e verifica la password.

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