[Advanced Excel] Freeze header row functionality
Question
excel-png
Web icon
Forge component by Carlos Freitas

Hello,


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?


Thanks!

Champion

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.


Regards

Champion

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.


mvp_badge
MVP

Hi Pedro

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

Hanno

Champion

Thanks Hanno,


Is the library used openxml?

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


https://forums.asp.net/t/2047728.aspx?Freeze+top+row+in+OpenXML

mvp_badge
MVP

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

Champion

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)


https://stackoverflow.com/a/28070406

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?


Danny

mvp_badge
MVP

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

do you have feature freeze header in this component?

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.