Freeze or Split Panes

Following sample 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.


1using System;
2using System.Collections.Generic;
3using System.Text;
4using GemBox.Spreadsheet;
5using GemBox.Spreadsheet.ConditionalFormatting;
6using GemBox.Spreadsheet.PivotTables;
7
8class Sample
9{
10    [STAThread]
11    static void Main(string[] args)
12    {
13        // If using Professional version, put your serial key below.
14        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");
15
16        ExcelFile ef = new ExcelFile();
17
18        // Frozen Rows (first 2 rows are frozen)
19        ExcelWorksheet ws1 = ef.Worksheets.Add("Frozen rows");
20        ws1.Panes = new WorksheetPanes(PanesState.Frozen, 0, 2, "A3", PanePosition.BottomLeft);
21
22        // Frozen Columns (first column is frozen)
23        ExcelWorksheet ws2 = ef.Worksheets.Add("Frozen columns");
24        ws2.Panes = new WorksheetPanes(PanesState.Frozen, 1, 0, "B1", PanePosition.TopRight);
25
26        // Frozen Rows and Columns (first 2 rows and first 3 columns are frozen)
27        ExcelWorksheet ws3 = ef.Worksheets.Add("Frozen rows and columns");
28        ws3.Panes = new WorksheetPanes(PanesState.Frozen, 3, 2, "E5", PanePosition.BottomRight);
29
30        // Split pane
31        ExcelWorksheet ws4 = ef.Worksheets.Add("Split pane");
32        ws4.Panes = new WorksheetPanes(PanesState.Split, 2310, 1500, "D7", PanePosition.BottomRight);
33
34        ef.Save("Freeze or Split Panes.xls");
35    }
36}
1Imports System
2Imports System.Collections.Generic
3Imports System.Text
4Imports GemBox.Spreadsheet
5Imports GemBox.Spreadsheet.ConditionalFormatting
6Imports GemBox.Spreadsheet.PivotTables
7
8Module Samples
9
10    Sub Main()
11
12        ' If using Professional version, put your serial key below.
13        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY")
14
15        Dim ef As ExcelFile = New ExcelFile
16
17        ' Frozen Rows (first 2 rows are frozen)
18        Dim ws1 As ExcelWorksheet = ef.Worksheets.Add("Frozen rows")
19        ws1.Panes = New WorksheetPanes(PanesState.Frozen, 0, 2, "A3", PanePosition.BottomLeft)
20
21        ' Frozen Columns (first column is frozen)
22        Dim ws2 As ExcelWorksheet = ef.Worksheets.Add("Frozen columns")
23        ws2.Panes = New WorksheetPanes(PanesState.Frozen, 1, 0, "B1", PanePosition.TopRight)
24
25        ' Frozen Rows and Columns (first 2 rows and first 3 columns are frozen)
26        Dim ws3 As ExcelWorksheet = ef.Worksheets.Add("Frozen rows and columns")
27        ws3.Panes = New WorksheetPanes(PanesState.Frozen, 3, 2, "E5", PanePosition.BottomRight)
28
29        ' Split pane
30        Dim ws4 As ExcelWorksheet = ef.Worksheets.Add("Split pane")
31        ws4.Panes = New WorksheetPanes(PanesState.Split, 2310, 1500, "D7", PanePosition.BottomRight)
32
33        ef.Save("Freeze or Split Panes.xls")
34
35    End Sub
36
37End Module

Check next sample or find out more about GemBox.Spreadsheet and GemBox Software.