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 for Python via .NET API kullanarak bir Excel dosyasını nasıl şifreleyip parola koruma altına alacağınızı gösterir.

from aspose.cells import EncryptionType, Workbook
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# The path to the documents directory.
dataDir = RunExamples.GetDataDir(".")
# Instantiate a Workbook object.
# Open an excel file.
workbook = Workbook(dataDir + "Book1.xls")
# Specify XOR encryption type.
workbook.set_encryption_options(EncryptionType.XOR, 40)
# Specify Strong Encryption type (RC4,Microsoft Strong Cryptographic Provider).
workbook.set_encryption_options(EncryptionType.STRONG_CRYPTOGRAPHIC_PROVIDER, 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 for Python via .NET API kullanarak Değiştirmek için Parola Microsoft Excel seçeneğinin nasıl ayarlanacağını gösterir.

from aspose.cells import Workbook
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# The path to the documents directory.
dataDir = RunExamples.GetDataDir(".")
# Instantiate a Workbook object.
# Open an excel file.
workbook = Workbook(dataDir + "Book1.xls")
# Set the password for modification.
workbook.settings.write_protection.password = "1234"
# Save the excel file.
workbook.save(dataDir + "SpecifyPasswordToModifyOption.out.xls")

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

Şifre korumalı Excel dosyasını açmak ve şifreyi çözmek Aspose.Cells for Python via .NET API kullanılarak aşağıdaki kodlar ile çok kolaydır:

from aspose.cells import LoadOptions, Workbook
# Open encrypted file with password.
loadOptions = LoadOptions()
loadOptions.password = "password"
workbook = Workbook("Book1.xlsx", loadOptions)
# Remove password.
workbook.settings.password = None
# Save the file.
workbook.save("Book1.xlsx")

Gelişmiş Konular