[Advanced Excel] Freeze header row functionality

Forge Component
Published on 2019-08-27 by Hanno
58 votes
Published on 2019-08-27 by Hanno


I would like to freeze the header row in in a created worksheet,but it seems there is no way to do that using the existing functionality. Anybody with a solution for this?


Hi Danny,

Are you using an excel template or creating a worksheet?

If you are using a template, you can lock the header directly in the template.


Hi again,

However, I found here in the "What's new" of the versions, the option "Locked" that should work for you. 

You just have to iterate through your header by setting the locked attribute to true.

Hi Pedro

Locked does not lock the cell for scrolling, but for editing.


Thanks Hanno,

Is the library used openxml?

If yes, so i think this functionality could be implemented.


We use the EPPlus c# library. And it can easily be added, yes.

"EPPlus is a .NET library that reads and writes Excel 2007/2010/2013 files using the Open Office Xml format (xlsx). EPPlus supports: Cell Ranges. Cell styling (Border, Color, Fill, Font, Number, Alignments)"
---- https://riptutorial.com/epplus

From the ExcelWorksheet object, access the View property. On the returned ExcelWorksheetView object, call the FreezePanes(row, column) method, passing in the row and column of the first cell which is not frozen.

For example, to freeze the first row, you would need to pass in 2 to the row parameter:

sheet.View.FreezePanes(2, 1)


Thank you both. Im not using a template, but creating a new worksheet indeed. Thats why this functionality could be helpfull to have available within the component.

@Hanno, is this something you are willing to add in the near future?


Absolutely, just pressed for time right now. Maybe over the weekend...