Excel Dosyalarını Şifrelemek ve Çözmek

Microsoft Excel Kullanımı

Microsoft Excel’de (burada Microsoft Excel 2003) dosya şifreleme ayarlarını yapmak için:

  1. Araçlar menüsünden Seçenekler‘i seçin. Bir iletişim kutusu görünecektir.
  2. Güvenlik sekmesini seçin.
  3. Bir parola girin ve Gelişmiş‘i tıklayın.
  4. Şifreleme türünü seçin ve parolayı onaylayın.

Aspose.Cells ile Excel dosyasının Şifrelenmesi

Aşağıdaki örnek, Aspose.Cells API’sını kullanarak bir Excel dosyasını şifrelemek ve parolayla korumak için nasıl yapılacağını göstermektedir.

// 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");

Değiştirilecek Parolayı Belirtme Seçeneği

Aşağıdaki örnek, mevcut bir dosya için Aspose.Cells API’sını kullanarak Değiştirilecek Parolayı Microsoft Excel seçeneğini nasıl ayarlayacağını göstermektedir.

// 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");

Aspose.Cells ile Excel dosyasının şifresini çözme

Koruma altındaki Excel dosyasını açmak ve Aspose.Cells API’sını kullanarak aşağıdaki kodları kullanarak şifresini çözmek çok kolaydır:

//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");

Gelişmiş Konular