on-internet
← Community

openpyxl: password protect entire excel file (xlsx)

Stack Overflow ·

I am trying to find pythonic ways to encrypt/password-protect excel xlsx files. Came across openpyxl, where in their documentation (https://openpyxl.readthedocs.io/en/stable/protection.html) states that it can do so. However, an error message AttributeError: 'NoneType' object has no attribute 'workbookPassword' is prompted when I executed the following. Help anyone? from openpyxl import workbook file = 'test.xlsx' // an existing xlsx wb = load_workbook(filename = file) wb.security.workbookPassword = 'test_password' wb.security.lockStructure = True Edit: I believe I have used the function impro

Comments

Sign in or sign up to comment and upvote.

No comments yet.