Skip to footer content

How to Add Freeze Panes to Spreadsheets in Excel

In this tutorial, we explore the process of adding freeze panes to Excel spreadsheets using C# and the IronXL library. The tutorial begins with installing IronXL via the NuGet package manager. Once set up, we delve into a pre-written code in the program.cs file. The code starts by importing the IronXL namespace and loading an existing Excel workbook into a workbook object. From this workbook, the first worksheet is extracted and stored in a worksheet object. To create a freeze pane, the 'create freeze pane' method is employed, which requires specifying the number of columns and rows to freeze. After modifying the worksheet, the workbook is saved with the 'save as' function. Additionally, a commented line of code is highlighted for removing existing freeze or split panes if necessary. Upon execution, the project successfully applies freeze panes to columns A and B and rows 1-3, ensuring that these sections remain visible when scrolling. This feature enhances data readability and accessibility. The tutorial concludes with a suggestion to explore a trial subscription to experience the full capabilities of the software.

Further Reading: How to Add Freeze Pane

Regan Pun
Software Engineer
Regan graduated from the University of Reading, with a BA in Electronic Engineering. Before joining Iron Software, his previous job roles had him laser-focused on single tasks; and what he most enjoys at Iron Software is the spectrum of work he gets to undertake, whether it’s adding value to sales, technical support, product development or marketing. He enjoys understanding the way developers are using the Iron Software library, and using that knowledge to continually improve documentation and develop the products.