# 设置表格结构保护sheet不可修改,不可重命名等
# 保护密码123
wb.security.workbook_password = '123'
wb.security.lockStructure = True
# 设置表格sheet保护sheet内容不可编辑修改
# 保护密码123
sheet1.protection.sheet = True
sheet1.protection.password = '123'
sheet1.protection.enable()
wb.save()
官方文档:https://openpyxl.readthedocs.io/en/latest/protection.html