Saturday, June 10, 2023

Freeze top row using Openpyxl

import openpyxl

#freeze and unfreeze using openpyxl
#open zomato spreadsheet

work_book=openpyxl.load_workbook(r'C:\Users\allso\Desktop\new vba projects\openpyxl\zomato.xlsx')


#select active sheet

sheet=work_book.active

#freeze the top row
#all rows above the current row and all columns left to the current column will be frozen

sheet.freeze_panes="A2"

#save the work book

work_book.save(r'C:\Users\allso\Desktop\new vba projects\openpyxl\zomato.xlsx')


No comments:

Post a Comment