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

باستخدام Microsoft إكسل

لتعيين إعدادات تشفير الملفات في Microsoft Excel (هنا Microsoft Excel 2003):

  1. منأدوات القائمة ، حددخياراتسيظهر مربع حوار.
  2. حدد ملفحماية التبويب.
  3. أدخل كلمة مرور وانقرمتقدم
  4. اختر نوع التشفير وقم بتأكيد كلمة المرور.

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

يوضح المثال التالي كيفية تشفير وحماية كلمة المرور لملف excel باستخدام Aspose.Cells API.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Instantiate a Workbook object.
// Open an excel file.
Workbook workbook = new Workbook(dataDir + "Book1.xls");
// Specify XOR encryption type.
workbook.SetEncryptionOptions(EncryptionType.XOR, 40);
// Specify Strong Encryption type (RC4,Microsoft Strong Cryptographic Provider).
workbook.SetEncryptionOptions(EncryptionType.StrongCryptographicProvider, 128);
// Password protect the file.
workbook.Settings.Password = "1234";
// Save the excel file.
workbook.Save(dataDir + "encryptedBook1.out.xls");

تحديد كلمة المرور لتعديل الخيار

يوضح المثال التالي كيفية تعيين ملفكلمة مرور للتعديل خيار Microsoft Excel لملف موجود باستخدام Aspose.Cells API.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Instantiate a Workbook object.
// Open an excel file.
Workbook workbook = new Workbook(dataDir + "Book1.xls");
// Set the password for modification.
workbook.Settings.WriteProtection.Password = "1234";
// Save the excel file.
workbook.Save(dataDir + "SpecifyPasswordToModifyOption.out.xls");

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

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

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

موضوعات مسبقة