Set Password for excel file using Python [duplicate]

删除回忆录丶 提交于 2019-12-11 01:32:19

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!