Freezing columns in EPPlus (an Excel split function)

It turns out that EPPlus has a built-in function for doing that on the Worksheet object itself called FreezePanes. This function has 2 parameters, both of which are int: Row and Column. Doing this will freeze whatever rows or columns you wish to have locked in place while viewing the worksheet.

One of the examples on the EPPlus website uses it, although it’s not the main focus of the example/ That example can be found here.

There is one gotcha with this function that you should know about, though: The number that you use for the row or column parameter is actually the first column that is NOT frozen in place. In other words, if you want the first 5 columns to be frozen you would have to make the following call:

ws.View.FreezePanes(1,6) (Where 6 is the first column that is not frozen)

Leave a Comment