Document Solutions for Excel, .NET Edition | Document Solutions
Features / Worksheet / Freeze Trailing Panes in a Worksheet
In This Topic
    Freeze Trailing Panes in a Worksheet
    In This Topic

    DsExcel allows users to freeze trailing panes in a worksheet. The trailing panes correspond to the rows and columns at the extreme bottom and right of the worksheet. Hence, it enables users to keep those specific rows or columns visible while scrolling through the rest of the sheet.

    However, the frozen trailing panes are only visible while interacting with SpreadJS by doing JSON I/O and are not visible in Excel or PDF.

    Freeze Trailing Panes

    The trailing panes in a worksheet can be frozen by using the FreezeTrailingPanes method of IWorksheet interface which takes row and column positions as parameters. The number of frozen rows and column can also be retrieved by using the FreezeTrailingRow and FreezeTrailingColumn properties respectively.

    Refer to the following example code to freeze trailing panes and retrieve the number of trailing frozen rows and columns in a worksheet.

    C#
    Copy Code
    //create a new workbook
    var workbook = new Workbook();
    
    //use sheet index to get worksheet
    IWorksheet worksheet = workbook.Worksheets[0];
    
    //freeze trailing pane
    worksheet.FreezeTrailingPanes(2, 3);
    
    //get the number of frozen trailing rows and columns
    Console.WriteLine("Number of trailing rows and columns" + worksheet.FreezeTrailingRow + worksheet.FreezeTrailingColumn);
    
    System.IO.File.WriteAllText("freezetrailingrowscolumns.ssjson", workbook.ToJson());

    Unfreeze Trailing Panes

    Similarly, the frozen trailing panes can be unfrozen by using the UnfreezeTrailingPanes method of IWorksheet interface.

    Refer to the following example code to unfreeze trailing panes in a worksheet.

    C#
    Copy Code
    //create a new workbook
    var workbook = new Workbook();
    
    //use sheet index to get worksheet
    IWorksheet worksheet = workbook.Worksheets[0];
    
    //freeze trailing pane
    worksheet.FreezeTrailingPanes(2, 3);
    
    //unfreeze trailing pane
    worksheet.UnfreezeTrailingPanes();
    
    System.IO.File.WriteAllText("unfreezetrailingrowscolumns.ssjson", workbook.ToJson());