الكشف عما إذا كانت ورقة العمل محمية بكلمة مرور
Contents
[
Hide
]
من الممكن حماية مصنفات العمل وأوراق العمل بشكل منفصل. على سبيل المثال، قد تحتوي جدول بيانات على ورقة عمل أو أكثر محمية بكلمة مرور، ومع ذلك، قد تكون جدول البيانات ذاته محمياً أو قد لا يكون كذلك. توفر واجهات برمجة التطبيقات Aspose.Cells الوسائل للكشف ما إذا كانت ورقة العمل المعطاة محمية بكلمة مرور أم لا. يوضح هذا المقال استخدام Aspose.Cells for Java API لتحقيق النتيجة نفسها.
الكشف عما إذا كانت ورقة العمل محمية بكلمة مرور
Aspose.Cells for Java 8.7.0 قد عرض الخاصية Protection.isProtectedWithPassword للكشف ما إذا كانت ورقة العمل محمية بكلمة مرور أم لا. تعيد الحقل البولياني Protection.isProtectedWithPassword صحيح إذا كانت Worksheet محمية بكلمة مرور وخاطئة إذا لم تكن محمية بكلمة مرور.
This file contains 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(DetectWorksheetisPasswordProtected.class); | |
// Create an instance of Workbook and load a spreadsheet | |
Workbook book = new Workbook(dataDir + "sample.xlsx"); | |
// Access the protected Worksheet | |
Worksheet sheet = book.getWorksheets().get(0); | |
// Check if Worksheet is password protected | |
if (sheet.getProtection().isProtectedWithPassword()) { | |
System.out.println("Worksheet is password protected"); | |
} |