Freezing columns in EPPlus (an Excel split function)

后端 未结 2 1274
滥情空心
滥情空心 2021-02-05 01:22

I\'ve been working a lot with EPPlus to generate Excel files for the number of exports that my project requires me to do. Most of the exports that they want tend to match up per

相关标签:
2条回答
  • 2021-02-05 01:30

    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)

    0 讨论(0)
  • 2021-02-05 01:35

    I realized that when using @IronMan84's suggestion, if you're only interested in the row but not the column. You can use

    ws.View.FreezePanes(3, 1); // (Freeze Row 2 and no column)
    
    0 讨论(0)
提交回复
热议问题