翻譯|使用教程|編輯:李顯亮|2021-06-02 10:17:49.787|閱讀 4021 次
概述:安全和隱私一直是保護數(shù)據(jù)的重要方面。由于 Excel 文件被廣泛用于存儲數(shù)據(jù),因此可以確保安全,避免篡改和未經(jīng)授權(quán)的訪問。據(jù)此,本文介紹了如何在 Python 中加密和解密 Excel 文件。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
安全和隱私一直是保護數(shù)據(jù)的重要方面。由于 Excel 文件被廣泛用于存儲數(shù)據(jù),因此可以確保安全,避免篡改和未經(jīng)授權(quán)的訪問。據(jù)此,本文介紹了如何在 Python 中加密和解密 Excel 文件。
為了加密和解密 Excel 文件,我們將使用Aspose.Cells for Python via Java除了對 Excel 文件的保護外,該 API 還支持動態(tài)生成、修改和轉(zhuǎn)換 Excel 文件。你可以點擊下方按鈕獲取使用。
點擊下載Aspose.Cells for Python via Java
以下是在 Python 中加密 Excel 文件的步驟。
以下代碼示例展示了如何在 Python 中加密 Excel 文件。
# Load XLSX workbook wb = Workbook("workbook.xlsx") # Password protect Excel file wb.getSettings().setPassword("1234") # Encrypt by specifying the encryption type wb.setEncryptionOptions(EncryptionType.XOR, 40) # Specify Strong Encryption type (RC4,Microsoft Strong Cryptographic Provider) wb.setEncryptionOptions(EncryptionType.STRONG_CRYPTOGRAPHIC_PROVIDER, 128) # Save Excel file wb.save("workbook-encrypted.xlsx")
以下是在 Python 中解密 Excel 文件的步驟。
以下代碼示例展示了如何在 Python 中解密 Excel 文件。
# Create load options loadOptions = LoadOptions(LoadFormat.XLSX) # Set original password loadOptions.setPassword("1234") # Load the Excel file wb = Workbook("workbook-encrypted.xlsx", loadOptions) # Set password to none wb.getSettings().setPassword(None) # Save Excel file wb.save("workbook-decrypted.xlsx")
如果你想試用Aspose的全部完整功能,可聯(lián)系在線客服獲取30天臨時授權(quán)體驗。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn