GemBox.Spreadsheet is a .NET component that enables you to read, write, edit, convert, and print spreadsheet files from your .NET applications using one simple API.

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.

Screenshot
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;

class Sample
{
    [STAThread]
    static void Main(string[] args)
    {
        // If using Professional version, put your serial key below.
        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");

        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

Module Samples

    Sub Main()

        ' If using Professional version, put your serial key below.
        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY")

        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

Check next sample.