Kryptera och dekryptera Excel-filer

Använder Microsoft Excel

Så här ställer du in filkrypteringsinställningar i Microsoft Excel (här Microsoft Excel 2003):

  1. FrånVerktyg menyn, väljalternativEn dialogruta visas.
  2. Väljsäkerhet flik.
  3. Ange ett lösenord och klickaAvancerad
  4. Välj krypteringstyp och bekräfta lösenordet.

Krypterar Excel-fil med Aspose.Cells

Följande exempel visar hur man krypterar och lösenordsskyddar en excel-fil med Aspose.Cells API.

# Open an excel file.
workbook = Workbook("Book1.xls")
# Password protect the file.
workbook.getSettings().setPassword("1234")
# Save the excel file.
workbook.save("encryptedBook1.out.xlsx")

Dekrypterar Excel-fil med Aspose.Cells

Det är mycket att öppna lösenordsskyddad excel-fil och dekryptera med Aspose.Cells API som följande koder:

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