Spread.Services provides you with the ability to freeze panes in a worksheet. This feature enables you to keep some specific rows or columns visible while users are scrolling through the rest of the sheet.
This functionality is particularly useful when there is a large amount of data that spans across a number of rows or columns.
You can freeze panes in a worksheet using the FreezePanes() method of the IWorksheet interface. This method will freeze the split panes according to the incoming row index and column index parameters.
In order to represent the row of freeze position and the column of freeze position, you can use the FreezeRow and FreezeColumn properties respectively.
Refer to the following example code to see how you can freeze panes in a worksheet.
C# |
Copy Code |
---|---|
// Adding worksheets to the workbook IWorksheet worksheet1 = workbook.Worksheets[0]; IWorksheet worksheet2 = workbook.Worksheets.Add(); IWorksheet worksheet3 = workbook.Worksheets.Add(); IWorksheet worksheet4 = workbook.Worksheets.Add(); //Freeze Panes worksheet1.FreezePanes(2, 3); worksheet2.FreezePanes(0, 2); worksheet3.FreezePanes(3, 0); worksheet4.FreezePanes(3, 5); |
You can unfreeze the split panes using the UnfreezePanes() method of the IWorksheet interface.
Refer to the following example code to unfreeze panes in a worksheet.
C# |
Copy Code |
---|---|
//UnFreeze Panes
worksheet4.UnfreezePanes(); |