Search code examples
c#export-to-excelspreadsheetgear

freeze top row using spreadsheetgear


How can I freeze top row (and only the row) using spreadsheetgear?

when I try this:

worksheet.WindowInfo.FreezePanes = true;

It freezes both the top row and the first column (A). I only need it to freeze the top row.


Solution

  • After some research I found out I need to select the cell first and then set the FreezePanes property:

    worksheet.Cells[1,0].Select();
    worksheet.WindowInfo.FreezePanes = true;
    

    Basically what happens is it freezes rows above and columns to the left of the selected cell.