تحقق من كلمة المرور للتعديل باستخدام Aspose.Cells

كود Java للتحقق من كلمة المرور للتعديل باستخدام Aspose.Cells

تقوم الرموز النموذجية التالية بتحميل ملفمصدر Excel ملف. يحتوي على كلمة مرور لفتح باسم1234 وكلمة المرور للتعديل باسم5678 . يتحقق الرمز أولاً مما إذا كان567 هي كلمة مرور صحيحة للتعديل وتعودخاطئة ثم يتحقق مما إذا كان5678 هي كلمة مرور للتعديل وتعودحقيقي.

// 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.getSharedDataDir(CheckPassword.class) + "articles/";
// Specify password to open inside the load options
LoadOptions opts = new LoadOptions();
opts.setPassword("1234");
// Open the source Excel file with load options
Workbook workbook = new Workbook(dataDir + "Book1.xlsx", opts);
// Check if 567 is Password to modify
boolean ret = workbook.getSettings().getWriteProtection().validatePassword("567");
System.out.println("Is 567 correct Password to modify: " + ret);
// Check if 5678 is Password to modify
ret = workbook.getSettings().getWriteProtection().validatePassword("5678");
System.out.println("Is 5678 correct Password to modify: " + ret);

تم إنشاء خرج وحدة التحكم بواسطة كود Java

إليك إخراج وحدة التحكم لعينة التعليمات البرمجية أعلاه بعد تحميل ملفمصدر Excel ملف.

Is 567 correct Password to modify: false

Is 5678 correct Password to modify: true