Freeze Panes in Excel
from ironxl import *

# Load the Excel workbook
workbook = WorkBook.Load("sample.xls")
worksheet = workbook.WorkSheets[0]

# Create freeze pane from column(A-B) and row(1-3)
worksheet.CreateFreezePane(2, 3)

# Overwriting freeze or split pane to column(A-E) and row(1-5) as well as applying prescroll
# The column will show E, G, ... and the row will show 5, 8, ...
worksheet.CreateFreezePane(5, 5, 6, 7)

# Save changes with the created freeze panes
workbook.SaveAs("createFreezePanes.xls")

# Remove all existing freeze or split pane
worksheet.RemovePane()
pip install ironxl
Freeze Panes in Excel

Freeze Panes in Excel

The code example above shows how to create a freeze pane in Excel using IronXL for Python, locking rows and columns so they remain visible while scrolling. This is a valuable feature for keeping header rows or label columns in place when reviewing large datasets.

CreateFreezePane(column, row)

The first CreateFreezePane overload takes a column count and a row count to define the frozen area. For example, worksheet.CreateFreezePane(1, 4) creates a freeze pane covering column A and rows 1-4.

CreateFreezePane(column, row, subsequentColumn, subsequentRow)

This overload creates a freeze pane and also applies pre-scrolling to the worksheet. For example, worksheet.CreateFreezePane(5, 2, 6, 7) freezes columns A-E and rows 1-2, with the view scrolled to show 1 additional column and 5 additional rows. When the worksheet is first opened, it will display columns A-E, G-... and rows 1-2, 8-...

If you work with large data tables in Excel, freezing rows or columns keeps important labels visible while scrolling through the rest of the worksheet.

Learn How to Add Freeze Panes in Excel with Python

Ready to Get Started?

Version:2026.11just released