Freeze or Split Panes

Following example demonstrates how to create worksheet panes. Panes can be frozen, split and frozen/split.

Note that some values of PanePosition enumeration are invalid if the pane doesn't exist in the split.

Freeze or Split Panes Screenshot

See the full code below, use Run Example to execute.

using System;
using System.Collections.Generic;
using System.Text;
using GemBox.Spreadsheet;
using GemBox.Spreadsheet.ConditionalFormatting;
using GemBox.Spreadsheet.PivotTables;
using GemBox.Spreadsheet.Tables;

class Sample
    static void Main(string[] args)
        // If using Professional version, put your serial key below.

        ExcelFile ef = new ExcelFile();

        // Frozen Rows (first 2 rows are frozen)
        ExcelWorksheet ws1 = ef.Worksheets.Add("Frozen rows");
        ws1.Panes = new WorksheetPanes(PanesState.Frozen, 0, 2, "A3", PanePosition.BottomLeft);

        // Frozen Columns (first column is frozen)
        ExcelWorksheet ws2 = ef.Worksheets.Add("Frozen columns");
        ws2.Panes = new WorksheetPanes(PanesState.Frozen, 1, 0, "B1", PanePosition.TopRight);

        // Frozen Rows and Columns (first 2 rows and first 3 columns are frozen)
        ExcelWorksheet ws3 = ef.Worksheets.Add("Frozen rows and columns");
        ws3.Panes = new WorksheetPanes(PanesState.Frozen, 3, 2, "E5", PanePosition.BottomRight);

        // Split pane
        ExcelWorksheet ws4 = ef.Worksheets.Add("Split pane");
        ws4.Panes = new WorksheetPanes(PanesState.Split, 2310, 1500, "D7", PanePosition.BottomRight);

        ef.Save("Freeze or Split Panes.xlsx");
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports GemBox.Spreadsheet
Imports GemBox.Spreadsheet.ConditionalFormatting
Imports GemBox.Spreadsheet.PivotTables
Imports GemBox.Spreadsheet.Tables

Module Samples

    Sub Main()

        ' If using Professional version, put your serial key below.

        Dim ef As ExcelFile = New ExcelFile

        ' Frozen Rows (first 2 rows are frozen)
        Dim ws1 As ExcelWorksheet = ef.Worksheets.Add("Frozen rows")
        ws1.Panes = New WorksheetPanes(PanesState.Frozen, 0, 2, "A3", PanePosition.BottomLeft)

        ' Frozen Columns (first column is frozen)
        Dim ws2 As ExcelWorksheet = ef.Worksheets.Add("Frozen columns")
        ws2.Panes = New WorksheetPanes(PanesState.Frozen, 1, 0, "B1", PanePosition.TopRight)

        ' Frozen Rows and Columns (first 2 rows and first 3 columns are frozen)
        Dim ws3 As ExcelWorksheet = ef.Worksheets.Add("Frozen rows and columns")
        ws3.Panes = New WorksheetPanes(PanesState.Frozen, 3, 2, "E5", PanePosition.BottomRight)

        ' Split pane
        Dim ws4 As ExcelWorksheet = ef.Worksheets.Add("Split pane")
        ws4.Panes = New WorksheetPanes(PanesState.Split, 2310, 1500, "D7", PanePosition.BottomRight)

        ef.Save("Freeze or Split Panes.xlsx")

    End Sub

End Module