Method
from openpyxl.styles import Protection
#Set protection
ws[‘C3’].protection=Protection(locked=True)
ws[‘C3′]=’abc123’
ws.protection.sheet=True
Sample Code
#Cell Style: Setting Protection
#Import load_workbook function
from openpyxl import Workbook
#Create a new workbook
wb=Workbook()
#Get the active worksheet
ws=wb.active
#Import Protection class
from openpyxl.styles import Protection
#Set protection
ws['C3'].protection=Protection(locked=False)
ws['C3']='abc123'
ws.protection.sheet=True
wb.save('test.xlsx')
wb.close()
