问题
I am trying to set password for excel file generated using openpyxl. I went through openpyxl. Openpyxl has a workbook protection functionality, but it does not support whole workbook lock using password as it does in MS Excel. I also looked into xlsxwriter, xlrd, xlwt.
Is there any way in python which i can set password for an excel file ?
Thanks in advance.
回答1:
Can you try using the below code,
from openpyxl import Workbook
wb = Workbook()
ws=wb.worksheets[0]
ws.protection.set_password('test')
wb.save('sample.xlsx')
来源:https://stackoverflow.com/questions/47918949/set-password-for-excel-file-using-python