officefileapi-403951-spreadsheet-document-api-examples-rows-and-columns-how-to-freeze-and-unfreeze-rows-and-columns.md
This topic describes how to keep specific rows and columns visible while you scroll through the worksheet.
Call one of the Worksheet.FreezeRows method overloads to freeze a specific number of rows at the top of the worksheet.
The following code snippet freezes the first row:
using DevExpress.Spreadsheet;
// ...
using (var workbook = new Workbook()) {
// Access the first worksheet in the workbook.
var worksheet = workbook.Worksheets[0];
// Freeze the top row in the worksheet.
worksheet.FreezeRows(0);
}
Imports DevExpress.Spreadsheet
' ...
Using workbook As New Workbook()
' Access the first worksheet in the workbook.
Dim worksheet As Worksheet = workbook.Worksheets(0)
' Freeze the top row in the worksheet.
worksheet.FreezeRows(0)
End Using
Call one of the Worksheet.FreezeColumns method overloads to freeze a specific number of columns on the left side of the worksheet.
The following code snippet freezes the first column:
using DevExpress.Spreadsheet;
// ...
using (var workbook = new Workbook()) {
// Access the first worksheet in the workbook.
var worksheet = workbook.Worksheets[0];
// Freeze the first column in the worksheet.
worksheet.FreezeColumns(0);
}
Imports DevExpress.Spreadsheet
' ...
Using workbook As New Workbook()
' Access the first worksheet in the workbook.
Dim worksheet As Worksheet = workbook.Worksheets(0)
' Freeze the first column in the worksheet.
worksheet.FreezeColumns(0)
End Using
Call one of the Worksheet.FreezePanes method overloads to freeze a specific number of topmost rows and leftmost columns in the worksheet.
The following code snippet freezes a pane that contains the first row and the first column:
using DevExpress.Spreadsheet;
// ...
using (var workbook = new Workbook()) {
// Access the first worksheet in the workbook.
var worksheet = workbook.Worksheets[0];
// Freeze the first row and the first column in the worksheet.
worksheet.FreezePanes(0,0);
}
Imports DevExpress.Spreadsheet
' ...
Using workbook As New Workbook()
' Access the first worksheet in the workbook.
Dim worksheet As Worksheet = workbook.Worksheets(0)
' Freeze the first row and the first column in the worksheet.
worksheet.FreezePanes(0,0)
End Using
Call the Worksheet.UnfreezePanes method to unlock the frozen rows and columns in the worksheet.
worksheet.UnfreezePanes();
worksheet.UnfreezePanes()