How To Freeze Cells Using OpenPyXL?

Method

ws.freeze_panes = ‘B2’

Sample Code

#Freeze the Cells

#Import load_workbook function
from openpyxl import Workbook

#Create a new workbook
wb=Workbook()
#Get the active worksheet
ws=wb.active

#Freeze a cell
ws.freeze_panes = 'B2'

wb.save('test.xlsx')
wb.close()
Freeze Cells Using OpenPyXL

Leave a Reply

Your email address will not be published. Required fields are marked *