python 生成excel 设置密码

from openpyxl import Workbook

wb = Workbook() # 创建一个工作表
ws = wb.active # ws操作sheet页
ws1 = wb.create_sheet('Mysheetfirst', 0)

ws1.protection.sheet = True
ws1.protection.password = '1234567890'
ws1.protection.enable()

---------------------------------------------------------

ws1['A1'] = 'juankuan'
ws1['E1'] = '中国'
ws1['F1'] = '2020-02-27-09-51-02'

-----------------------------------------------

wb.save('xxxxxx.xlsx')

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容