You can choose to show or hide rows and columns in a sheet by following one of the methods below:
You can also hide row headers and column headers. For more information, refer to Showing or Hiding Headers.
The following code sample demonstrates the use of SheetView methods as well as Rows and Columns properties to hide the first row and the second column.
C# |
Copy Code
|
---|---|
//Using SheetView methods to set visibility fpSpread1.Sheets[0].SetColumnVisible(1,false); fpSpread1.Sheets[0].SetRowVisible(0,false); //Another option - use the Visible property. fpSpread1.Sheets[0].Columns[1].Visible = false; fpSpread1.Sheets[0].Rows[0].Visible = false; //Another option - set row height or column width to zero. GrapeCity.Spreadsheet.IWorksheet sheet1 = fpSpread1.AsWorkbook().ActiveSheet sheet1.Columns[1].ColumnWidth = 0; sheet1.Rows[0].RowHeight = 0; |
VB |
Copy Code
|
---|---|
'Using SheetView methods to set visibility fpSpread1.Sheets(0).SetColumnVisible(1, False) fpSpread1.Sheets(0).SetRowVisible(0, False) 'Another option - use the Visible property. fpSpread1.Sheets(0).Columns(1).Visible = False fpSpread1.Sheets(0).Rows(0).Visible = False 'Another option - set row height or column width to zero. GrapeCity.Spreadsheet.IWorksheet sheet1 = fpSpread1.AsWorkbook().ActiveSheet sheet1.Columns(1).ColumnWidth = 0 sheet1.Rows(0).RowHeight = 0 |
By default, the width and height of hidden columns and rows are displayed by about 1 pixel when set to hidden. To eliminate this display, you need to set ResizeZeroIndicator to Default.
When you hide a row or column, the size of the row or column is remembered by the Spread component. If you re-display the row or column, it is displayed at the size it was before it was hidden.
Conversely, you can also prevent the user to re-display the hidden rows or columns by setting the Row.Resizable or Column.Resizable properties to false.
If you want to determine if a row or column is presently visible to the user, that is, whether it appears in the viewport that is currently being displayed, you can use the FpSpread class methods. For more information refer to Customizing Viewports.