تحقق من كلمة المرور المستخدمة لحماية ورقة العمل
Contents
[
Hide
]
Aspose.Cells عززت واجهات برمجة التطبيقاتحماية class عن طريق إدخال بعض الخصائص والأساليب المفيدة. أحد هذه الطرق هو[اكد كلمة المرور](https://reference.aspose.com/cells/java/com.aspose.cells/protection#verifyPassword(java.lang.String)الذي يسمح بتحديد كلمة مرور كمثيل لـ String والتحقق من استخدام نفس كلمة المرور لحماية ورقة العمل.
تحقق من كلمة المرور المستخدمة لحماية ورقة العمل
الالحماية طريقة إرجاعحقيقي إذا كانت كلمة المرور المحددة تتطابق مع كلمة المرور المستخدمة لحماية ورقة العمل المحددة ،خاطئة إذا كانت كلمة المرور المحددة غير متطابقة. الجزء التالي من التعليمات البرمجية يستخدمالحماية بالاشتراك معProtection.isProtectedWithPasswordخاصية الكشف عن حماية كلمة المرور ، والتحقق من كلمة المرور.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(VerifyPasswordtoProtectWorksheet.class); | |
// Create an instance of Workbook and load a spreadsheet | |
Workbook book = new Workbook(dataDir + "book1.xlsx"); | |
// Access the protected Worksheet | |
Worksheet sheet = book.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("password")) { | |
System.out.println("Specified password has matched"); | |
} else { | |
System.out.println("Specified password has not matched"); | |
} | |
} |