تشفير وفك تشفير ملفات Excel

استخدام برنامج MS Excel

في MS Excel (مثل MS Excel 2003)، لتنفيذ إعدادات تشفير الملف، يمكنك محاولة:

  • من قائمة الأدوات، حدد الخيارات، ثم حدد علامة التبويب الأمان.
  • إدخال كلمة المرور للفتح وانقر على زر متقدم.
  • اختر نوع التشفير وقم بتأكيد كلمة المرور.

todo:image_alt_text

الشكل: مربع حوار الخيارات

todo:image_alt_text

الشكل: مربع حوار نوع التشفير

تشفير ملف Excel

يوضح المثال التالي كيف يمكنك تشفير / حماية ملف Excel باستخدام واجهة برمجة التطبيقات لـ Aspose.Cells.

كود عينة:

// 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(EncryptingFiles.class) + "loading_saving/";
// Instantiate a Workbook object by excel file path
Workbook workbook = new Workbook(dataDir + "Book1.xls");
// Password protect the file.
workbook.getSettings().setPassword("1234");
// Specify XOR encrption type.
workbook.setEncryptionOptions(EncryptionType.XOR, 40);
// Specify Strong Encryption type (RC4,Microsoft Strong Cryptographic
// Provider).
workbook.setEncryptionOptions(EncryptionType.STRONG_CRYPTOGRAPHIC_PROVIDER, 128);
// Save the excel file.
workbook.save(dataDir + "EncryptingFiles_out.xls");
// Print message
System.out.println("Encryption applied successfully on output file.");

فك تشفير ملف Excel باستخدام Aspose.Cells

من السهل جداً فتح ملف Excel المحمي بكلمة مرور وفك تشفيره باستخدام واجهة برمجة التطبيقات Aspose.Cells كما يلي:

//Open encrypted file with password.
LoadOptions loadOptions = new LoadOptions();
loadOptions.setPassword("password");
Workbook workbook = new Workbook("Book1.xlsx", loadOptions);
//Remove password.
workbook.getSettings().setPassword(null);
//Save the file.
workbook.save("Book1.xlsx");