DEV Community

IronSoftware
IronSoftware

Posted on • Originally published at ironsoftware.com

Freeze Panes in Excel

Use freeze panes to lock specific rows and columns in place, allowing them to remain visible while scrolling.

If you have a large table of data in Excel, it can be useful to freeze rows or columns. This way you can keep rows or columns visible while scrolling through the rest of the worksheet.

C#:

using System.Linq;
using IronXL;

WorkBook workbook = WorkBook.Load("test.xls");
WorkSheet sheet = workbook.WorkSheets.First();

//This is how we can freeze specified amount of columns and rows.They will be visible while scrolling the screen
sheet.CreateFreezePane(2,5);

//sheet.RemovePane() can be used to remove this frozen pane.

workbook.SaveAs("CreateFreezePanes.xls");
Enter fullscreen mode Exit fullscreen mode

VB:

Imports System.Linq
Imports IronXL

Private workbook As WorkBook = WorkBook.Load("test.xls")
Private sheet As WorkSheet = workbook.WorkSheets.First()

'This is how we can freeze specified amount of columns and rows.They will be visible while scrolling the screen
sheet.CreateFreezePane(2,5)

'sheet.RemovePane() can be used to remove this frozen pane.

workbook.SaveAs("CreateFreezePanes.xls")
Enter fullscreen mode Exit fullscreen mode

Top comments (0)