# Rows and Columns

## Content



Worksheets have a grid layout that consists of rows and columns. These rows and columns are represented by [XLRow](/componentone/docs/win/online-excel/) and [XLColumn](/componentone/docs/win/online-excel/) classes, respectively. Lets discuss the operations that can be performed on rows and columns in a worksheet.

## Add Rows and Columns

You can add rows and columns in a worksheet by using [Add](/componentone/docs/win/online-excel/) method of the [XLRowCollection](/componentone/docs/win/online-excel/) and [XLColumnCollection](/componentone/docs/win/online-excel/) classes, respectively. The following code shows how you can add rows and columns to your worksheets in Excel.

```csharp
XLRow row1 = new XLRow();
//adds a row
sheet.Rows.Add(row1);
XLColumn col1 = new XLColumn();
//adds a column
sheet.Columns.Add(col1);
```

## Set Height and Width

You can set the height and width of rows and columns in a worksheet using [Height](/componentone/docs/win/online-excel/) property of the [XLRow](/componentone/docs/win/online-excel/) class and [Width](/componentone/docs/win/online-excel/) property of the [XLColumn](/componentone/docs/win/online-excel/) class.

![](https://cdn.mescius.io/document-site-files/images/2f1197a8-415d-4bfe-b1e0-0a66c2dd3972/images/height.png)

The following code shows how to set the height and width of rows and columns in Excel worksheet.

```csharp
//set height of row
row1.Height = 100;
//set width of column
col1.Width = 50;
```

## Hide Rows/Columns

You can choose to hide a specific row/column by setting its Visible property to **false**.

To hide a specific row/column in worksheet, use the following code.

```csharp
//hide a row
row1.Visible = false;
//hide a column
col1.Visible = false;
```

## Set Outline Levels

In Excel, outlines are used to display summary rows or columns. You can easily set outline levels for rows and columns in a worksheet by using [OutlineLevel](/componentone/docs/win/online-excel/) property of the [XLRow](/componentone/docs/win/online-excel/) and [XLColumn](/componentone/docs/win/online-excel/) class, respectively. For more information, see [Groups and Subtotals](/componentone/docs/win/online-excel/groupsandsubtotals).

The following code shows how you can set outline levels of rows and columns in Excel.

```csharp
//set outline level
row1.OutlineLevel= 10;
```