التحقق من كلمة المرور للتعديل باستخدام Aspose.Cells for Node.js via C++
WorkbookSettings.writeProtection.validatePassword()
التي يمكنك استخدامها للتحقق مما إذا كانت كلمة المرور للتعديل صحيحة أم لا.
التحقق من كلمة المرور للتعديل في Microsoft Excel
يمكنك تعيين كلمة السر للفتح وكلمة السر للتعديل أثناء إنشاء جداول البيانات الخاصة بك في Microsoft Excel. يُرجى الرجوع إلى هذا اللقط الشاشة الذي يظهر واجهة Microsoft Excel المُقدمة لتحديد هذه الكلمات السرية.
![]() |
---|
التحقق من كلمة المرور للتعديل باستخدام Aspose.Cells for Node.js via C++
يحمّل الأمثلة التالية ملف Excel المصدر (5112232.xlsx). يحتوي على كلمة مرور عند الفتح وهي 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);
مخرجات الوحدة
إليك مخرجات الكونسول للشيفرة العينة أعلاه بعد تحميل ملف الإكسل المصدري.
Is 567 correct Password to modify: False
Is 5678 correct Password to modify: True