Append/Insert/Delete Operations
To manage rows and columns, the worksheet provides methods for appending, inserting, and removing them:
var sheet = grid.CurrentWorksheet;
// Append rows or columns at the end
sheet.AppendRows(int rowCount);
sheet.AppendCols(int colCount);
// Insert rows or columns at a specified position
sheet.InsertRows(int rowIndex, int rowCount);
sheet.InsertCols(int colIndex, int colCount);
// Delete rows or columns starting from a specified position
sheet.DeleteRows(int rowIndex, int rowCount);
sheet.DeleteCols(int colIndex, int colCount);
In these methods, the first parameter specifies the zero-based index at which the operation begins, and the second parameter indicates the number of rows or columns to be affected.
Alternatively, you can use actions for inserting or removing rows and columns, which support undo, redo, and repeat:
// Insert rows or columns
var insertRowAction = new unvell.ReoGrid.Actions.InsertRowsAction(rowIndex, rowCount);
var insertColAction = new unvell.ReoGrid.Actions.InsertColumnsAction(colIndex, colCount);
// Remove rows or columns
var removeRowAction = new unvell.ReoGrid.Actions.RemoveRowsAction(rowIndex, rowCount);
var removeColAction = new unvell.ReoGrid.Actions.RemoveColumnsAction(colIndex, colCount);
// Execute actions
sheet.DoAction(insertRowAction);
sheet.DoAction(insertColAction);
sheet.DoAction(removeRowAction);
sheet.DoAction(removeColAction);
Setting Row and Column Counts
To modify the number of rows and columns in a worksheet, the following methods are available:
// To resize both rows and columns
sheet.Resize(int rowCount, int colCount);
// To adjust the number of rows or columns individually
sheet.SetRows(6); // Sets the number of rows
sheet.SetCols(5); // Sets the number of columns

Predefined Values
The table below shows the initial, minimum, and maximum values for various worksheet parameters, along with their data types:
| Initial | Minimum | Maximum | Data type | |
|---|---|---|---|---|
| Number of Rows | 200 | 1 | 1,048,576 | Paging-indexed two-dimensional array |
| Number of Columns | 100 | 1 | 32,768 | Paging-indexed two-dimensional array |
| Row Height (pixels) | 20 | 0 | 65,535 | ushort |
| Column Width (pixels) | 70 | 0 | 65,535 | ushort |
Adjusting Height and Width
To modify the height of rows or the width of columns, use the following methods:
// To set the height of all rows
sheet.SetRowsHeight(0, grid.RowCount, 10);
// To set the width of all columns
sheet.SetColsWidth(0, grid.ColCount, 10);

Alternatively, to adjust header sizes with undo support, use the following actions:
// To change the height of a range of rows
sheet.DoAction(new SetRowsHeightAction(0, 10, 30));
// To change the width of a range of columns
sheet.DoAction(new SetColumnsWidthAction(0, 10, 30));
::info
The SetRowsHeightAction and SetColumnsWidthAction constructors require specifying the starting index, the number of rows or columns to affect, and the new height or width in pixels. These actions are part of ReoGridβs undo/redo framework, allowing for more flexible document editing.
::

Auto row height
ReoGrid automatically adjusts the row height when a cell value changes through editing:

Disable auto adjusting
This behavior can be disabled for individual rows:
var rowHeader = sheet.RowHeaders[2];
rowHeader.IsAutoHeight = false;
Auto fit row height and column width
When you double-click on the separator between headers, ReoGrid adjusts the row height or column width to fit the largest cell.
Before:

After:

Code to do this programmatically:
sheet["A2"] = "This is a long text";
sheet.AutoFitColumnWidth(0, false);
The second argument specifies whether to use an action to perform this operation. Using an action enables undo via the Undo method or Ctrl+Z.
Hide & Unhide
Like Excel, ReoGrid supports hiding rows or columns. Call the following methods to hide or show rows or columns:
sheet.HideRows(int start, int count);
sheet.ShowRows(int start, int count);
sheet.HideColumns(int start, int count);
sheet.ShowColumns(int start, int count);
A hidden row or column is displayed as a single line.

Notes:
- Both
HideRowsandHideColumnswill automatically collapse any outlines whose rows or columns are being hidden. - Both
ShowRowsandShowColumnswill automatically expand any outlines whose rows or columns are being shown.
Example:
Hide rows grouped by an outline:
The outline will be collapsed automatically.

For more details, see Group & Outline.
Check for hidden headers and cells
Check whether a row or column is hidden:
bool Worksheet.IsHiddenRow(int row);
bool Worksheet.IsHiddenColumn(int col);
Check whether a cell is on a hidden row or column:
bool Worksheet.IsHiddenCell(int row, int col);
bool Worksheet.IsHiddenCell(string addressOrName);
bool Worksheet.IsHiddenCell(ReoGridCell cellInstance);
// or by calling from a cell instance
var cell = sheet.Cells["H8"];
bool hidden = cell.IsHidden;
Get the instances of header
// get worksheet instance from grid control
var sheet = grid.CurrentWorksheet;
// get header instances
var colHeader = sheet.ColumnHeaders[2];
var rowHeader = sheet.RowHeaders[3];
Change column header text
// set text of column header
colHeader.Text = "Product";

Change row header text
sheet.RowHeaders[1].Text = "Header";

Change row header width
You can change the width of the row header to display more text:
sheet.RowHeaderWidth = 100;
sheet.RowHeaders[1].Text = "Row Header";

Hide row via header instance
// hide 4th row (zero-based)
rowHeader.IsHidden = true;

Change width or height of header
sheet.RowHeaders[3].HeightInPixel = 30; // height in pixel
Performance difference between instance call and Control API
Some operations can be performed via either a header instance call or a control API call, but header instance calls may have a performance impact. For the example below, it is strongly recommended to use Method 2.
Method 1: Call header instance to change height of rows
sheet.RowHeaders[2].HeightInPixel = 30;
sheet.RowHeaders[3].HeightInPixel = 30;
sheet.RowHeaders[4].HeightInPixel = 30;
Method 2: Call control API to change height of rows
sheet.SetRowsHeight(2, 3, 30); // from index 2, rows is 3
Method 2 provides a significant performance advantage over Method 1.
Column Cells Type
You can specify a default cell type for an entire column.
// ColumnHeaders property returns an instance of column header
// it accepts a numeric index or an address string to locate a column
sheet.ColumnHeaders["A"].DefaultCellBody = typeof(unvell.ReoGrid.CellTypes.CheckBoxCell);
// set horizontal alignment for all cells in this column to center
sheet.ColumnHeaders["A"].Style.HorizontalAlign = ReoGridHorAlign.Center;
// give the check box a small padding (2 pixels)
sheet.ColumnHeaders["A"].Style.Padding = new System.Windows.Forms.Padding(2);
Setting the cell type alone will not cause any cells to be displayed; the cell body is displayed only when cell data is filled in.

sheet["A1:A5"] = new object[] { false, true, false, false, true };
The checkbox cell accepts a bool value as data; the grid is displayed as below:
