You can freeze rows or columns or both in a sheet to make them unscrollable.
The frozen top rows are called leading rows and the frozen left-most columns are called leading columns. The frozen leading rows and columns stay at the top and left of the view regardless of the scrolling.
You can set the number of frozen rows or columns by using the FrozenRowCount or FrozenColumnCount properties.
C# |
Copy Code
|
---|---|
// freeze rows and columns
FpSpread1.Sheets[0].FrozenColumnCount = 2;
FpSpread1.Sheets[0].FrozenRowCount = 2;
|
Visual Basic |
Copy Code
|
---|---|
'freeze rows And columns
FpSpread1.Sheets(0).FrozenColumnCount = 2
FpSpread1.Sheets(0).FrozenRowCount = 2
|
The frozen trailing rows and columns stay at the bottom and right of the view regardless of the scrolling.
You can set the number of frozen trailing bottom rows or trailing right-most columns by using FrozenTrailingColumnCount or FrozenTrailingRowCount properties.
When the height of data rows and frozen trailing rows is less than that of the viewport area, you can choose whether to display the blank space between the data rows and frozen trailing rows or not. The FrozenTrailingStickToEdge option can be used to control this behavior and accepts RowCol enumeration values such as Both (default), Rows, Columns, None.
When FrozenTrailingStickToEdge = Row | When FrozenTrailingStickToEdge = None |
---|---|
C# |
Copy Code
|
---|---|
fpSpread1.ActiveSheet.Rows.Count = 25; fpSpread1.ActiveSheet.Columns.Count = 20; fpSpread1.Sheets[0].FrozenTrailingRowCount = 5; fpSpread1.ActiveSheet.FrozenTrailingStickToEdge = FarPoint.Win.Spread.RowCol.Rows; |
Visual Basic |
Copy Code
|
---|---|
FpSpread1.ActiveSheet.Rows.Count = 25 FpSpread1.ActiveSheet.Columns.Count = 20 FpSpread1.Sheets(0).FrozenTrailingRowCount = 5 FpSpread1.ActiveSheet.FrozenTrailingStickToEdge = FarPoint.Win.Spread.RowCol.Rows |
When using the print option, trailing frozen rows and columns are not printed repeatedly at the bottom and right of every page, but print only once as the last row and column.
Leading frozen rows and columns can be repeatedly printed at the top and left of every page. For more information about repeating rows and columns, refer to Repeating Rows or Columns on Printed Pages.
You can specify the color of the line displayed between the frozen and non-frozen areas of the worksheet with the FrozenLineColor property in the WorksheetOptions class. By default, no color is set to show the frozen line.
The preferred frozen line color can be chosen by using Color methods.
C# |
Copy Code
|
---|---|
// freeze rows and columns fpSpread1.Sheets[0].FrozenColumnCount = 2; fpSpread1.Sheets[0].FrozenRowCount = 2; fpSpread1.Sheets[0].FrozenTrailingColumnCount = 2; fpSpread1.Sheets[0].FrozenTrailingRowCount = 2; // set frozen line color fpSpread1.AsWorkbook().Worksheets[0].Options.FrozenLineColor = GrapeCity.Spreadsheet.Color.FromArgb(0, 0, 255); |
Visual Basic |
Copy Code
|
---|---|
'freeze rows And columns FpSpread1.Sheets(0).FrozenColumnCount = 2 FpSpread1.Sheets(0).FrozenRowCount = 2 FpSpread1.Sheets(0).FrozenTrailingColumnCount = 2 FpSpread1.Sheets(0).FrozenTrailingRowCount = 2 'set frozen line color FpSpread1.AsWorkbook().Worksheets(0).Options.FrozenLineColor = GrapeCity.Spreadsheet.Color.FromArgb(0, 0, 255) |
You can specify or change the width of the displayed line between the frozen and non-frozen areas of the worksheet using FrozenLineThickness property from the WorksheetOptions class.
C# |
Copy Code
|
---|---|
fpSpread1.ActiveSheet.FrozenColumnCount = 3; fpSpread1.ActiveSheet.AsWorksheet().Options.FrozenLineThickness = 5; |
VB |
Copy Code
|
---|---|
fpSpread1.ActiveSheet.FrozenColumnCount = 3 fpSpread1.ActiveSheet.AsWorksheet().Options.FrozenLineThickness = 5 |