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')

你可能感兴趣的:(python 生成excel 设置密码)