Skip to main content
A newer version of this page is available. .

How to: Freeze Rows and Columns

  • 2 minutes to read

You can lock a number of top rows and left columns to keep an area of the worksheet permanently visible while scrolling another worksheet area. To do this, specify the position of a cell below the frozen rows and to the right of the frozen columns by creating the XlCellPosition object and assign it to the IXlSheet.SplitPosition property.

To freeze the first row, use the following code:

Note

A complete sample project is available at https://github.com/DevExpress-Examples/xl-export-api-examples-t253492

// Freeze the first row in the worksheet.
sheet.SplitPosition = new XlCellPosition(0, 1);

To freeze the first column, use the following code:

Note

A complete sample project is available at https://github.com/DevExpress-Examples/xl-export-api-examples-t253492

// Freeze the first column in the worksheet.
sheet.SplitPosition = new XlCellPosition(1, 0);

To freeze the pane which contains one topmost row and one leftmost column, use the following code:

Note

A complete sample project is available at https://github.com/DevExpress-Examples/xl-export-api-examples-t253492

// Freeze the first column and the first row.
sheet.SplitPosition = new XlCellPosition(1, 1);