كشف ما إذا كانت ورقة العمل محمية بكلمة مرور باستخدام Node.js عبر C++
Contents
[
Hide
]
من الممكن حماية دفاتر العمل وورقات العمل بشكل منفصل. على سبيل المثال، قد تحتوي ورقة عمل على واحدة أو أكثر من أوراق العمل التي تكون محمية بكلمة مرور، ومع ذلك، قد يكون دفتر العمل محميًا أو لا. توفر واجهة برمجة تطبيقات Aspose.Cells الوسائل للكشف إذا كانت ورقة العمل محمية بكلمة مرور أم لا. يوضح هذا المقال استخدام API Aspose.Cells for Node.js via C++ لتحقيق ذلك.
لقد قام Aspose.Cells for Node.js via C++ بكشف خاصية Protection.isProtectedWithPassword() للتمكن من تحديد ما إذا كانت ورقة العمل محمية بكلمة مرور أم لا. الخاصية Boolean Protection.isProtectedWithPassword() تعيد true إذا كانت ورقة العمل محمية بكلمة مرور وfalse إذا لم تكن كذلك.
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, "sample.xlsx");
// Create an instance of Workbook and load a spreadsheet
const book = new AsposeCells.Workbook(filePath);
// Access the protected Worksheet
const sheet = book.getWorksheets().get(0);
// Check if Worksheet is password protected
if (sheet.getProtection().isProtectedWithPassword()) {
console.log("Worksheet is password protected");
} else {
console.log("Worksheet is not password protected");
}