Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

Use the Excel Export API to Freeze Rows and Columns

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, create the XlCellPosition object to specify the position of a cell below the frozen rows and to the right of the frozen columns and assign it to the IXlSheet.SplitPosition property.

Important

If you create an XLSX document, specify the IXlSheet.SplitPosition property before you start generating columns, rows and cells.

To freeze the first row, use the following code:

View Example

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

To freeze the first column, use the following code:

// 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:

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