Workbook and worksheet protection fails
Created originally on Bitbucket by tristanbrown (Tristan Brown)
Tried:
#!python
from openpyxl import Workbook
def _create_template(headers):
template = Workbook()
sheet = template.active
sheet.append(headers)
template.security.workbook_Password = 'pw'
sheet.protection.sheet = True
sheet.protection.password = 'pw'
template.save(filename='template.xlsm')
When I run this function on a list of column headers and open template.xlsm, all cells are editable without a password. In addition to the above, I tried setting cell.protection = Protection(locked=True)
for the cells in the sheet, with no further success.