# Creating a Header with Multiple Rows or Columns

Learn how to programmatically create a hierarchical display with custom SheetView objects in this tutorial. Explore the example code for creating parent-child relations and assigning child sheets to parent rows.

## Content

You can provide multiple rows in the column header and multiple columns in the row header. As shown in the following figure, the headers may have different numbers of columns and rows.
![Spread with multiple column header rows](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/hdrmulti1.png)
The rows or columns in the header can also contain spans, for example, if you want to have a header cell that explains two cells beneath it (or subheaders). For instructions for creating a span in a header, see [Creating a Span in a Header](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-header/spwin-headerspan).
You can customize the labels in these headers. For instructions for customizing the labels, see [Customizing Header Label Text](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-header/spwin-headertext/spwin-headerlabel). For more information on the individual properties, refer to the [Column](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.Column.html) [Label](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.Column.Label.html) property or the [Row](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.Row.html) [Label](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.Row.Label.html) property.

## Using the Properties Window

1. At design time, in the **Properties** window, select the Spread component.
2. Select the **Sheets** property.
3. Click the button to display the **SheetView Collection Editor**.
4. Click the sheet for which you want to change the header display.
5. Set the **ColumnHeaderRowCount** property to the number or rows you want in the column header or the **RowHeaderColumnCount** property to the number of columns you want in the row header.
6. Click **OK** to close the editor.

## Using a Shortcut

Set the [ColumnHeaderRowCount](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.ColumnHeaderRowCount.html) property or the [RowHeaderColumnCount](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.RowHeaderColumnCount.html) property for a Sheets object. Use the [AddColumnHeaderSpanCell](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.AddColumnHeaderSpanCell.html) method to span the cells in the header. Use the **Label** and **Text** properties to add the labels to the header cells.

## Example

This example code creates a spreadsheet shown in the figure above, with two columns in the row header and three rows in the column header.

```csharp
// Set the number or rows and columns in the headers.
fpSpread1.Sheets[0].ColumnHeaderRowCount = 3;
fpSpread1.Sheets[0].RowHeaderColumnCount = 2;
// Span the header cells as needed.
fpSpread1.Sheets[0].AddColumnHeaderSpanCell(1, 0, 1, 2);
fpSpread1.Sheets[0].AddColumnHeaderSpanCell(1, 2, 1, 2);
fpSpread1.Sheets[0].AddColumnHeaderSpanCell(1, 4, 1, 2);
fpSpread1.Sheets[0].AddColumnHeaderSpanCell(1, 6, 1, 2);
fpSpread1.Sheets[0].AddColumnHeaderSpanCell(0, 0, 1, 8);
fpSpread1.Sheets[0].AddRowHeaderSpanCell(0, 0, 12, 1);
// Set the labels as needed -- using the Label property or
// the cell Text property.
fpSpread1.Sheets[0].ColumnHeader.Columns[0].Label = "East";
fpSpread1.Sheets[0].ColumnHeader.Columns[1].Label = "West";
fpSpread1.Sheets[0].ColumnHeader.Columns[2].Label = "East";
fpSpread1.Sheets[0].ColumnHeader.Columns[3].Label = "West";
fpSpread1.Sheets[0].ColumnHeader.Columns[4].Label = "East";
fpSpread1.Sheets[0].ColumnHeader.Columns[5].Label = "West";
fpSpread1.Sheets[0].ColumnHeader.Columns[6].Label = "East";
fpSpread1.Sheets[0].ColumnHeader.Columns[7].Label = "West";
fpSpread1.Sheets[0].ColumnHeader.Cells[0,0].Text = "Fiscal Year 2004";
fpSpread1.Sheets[0].ColumnHeader.Cells[1,0].Text = "1st Quarter";
fpSpread1.Sheets[0].ColumnHeader.Cells[1,2].Text = "2nd Quarter";
fpSpread1.Sheets[0].ColumnHeader.Cells[1,4].Text = "3rd Quarter";
fpSpread1.Sheets[0].ColumnHeader.Cells[1,6].Text = "4th Quarter";
// Set the row header so that the label displays.
fpSpread1.Sheets[0].RowHeader.Columns[0].Width = 45;
fpSpread1.Sheets[0].RowHeader.Cells[0,0].Text = "Branch #";
```

```vbnet
’ Set the number or rows and columns in the headers.
fpSpread1.Sheets(0).ColumnHeaderRowCount = 3
fpSpread1.Sheets(0).RowHeaderColumnCount = 2
’ Span the header cells as needed.
fpSpread1.Sheets(0).AddColumnHeaderSpanCell(1, 0, 1, 2)
fpSpread1.Sheets(0).AddColumnHeaderSpanCell(1, 2, 1, 2)
fpSpread1.Sheets(0).AddColumnHeaderSpanCell(1, 4, 1, 2)
fpSpread1.Sheets(0).AddColumnHeaderSpanCell(1, 6, 1, 2)
fpSpread1.Sheets(0).AddColumnHeaderSpanCell(0, 0, 1, 8)
fpSpread1.Sheets(0).AddRowHeaderSpanCell(0, 0, 12, 1)
’ Set the labels as needed -- using the Label property or
’ the cell Text property.
fpSpread1.Sheets(0).ColumnHeader.Columns(0).Label = "East"
fpSpread1.Sheets(0).ColumnHeader.Columns(1).Label = "West"
fpSpread1.Sheets(0).ColumnHeader.Columns(2).Label = "East"
fpSpread1.Sheets(0).ColumnHeader.Columns(3).Label = "West"
fpSpread1.Sheets(0).ColumnHeader.Columns(4).Label = "East"
fpSpread1.Sheets(0).ColumnHeader.Columns(5).Label = "West"
fpSpread1.Sheets(0).ColumnHeader.Columns(6).Label = "East"
fpSpread1.Sheets(0).ColumnHeader.Columns(7).Label = "West"
fpSpread1.Sheets(0).ColumnHeader.Cells(0,0).Text = "Fiscal Year 2004"
fpSpread1.Sheets(0).ColumnHeader.Cells(1,0).Text = "1st Quarter"
fpSpread1.Sheets(0).ColumnHeader.Cells(1,2).Text = "2nd Quarter"
fpSpread1.Sheets(0).ColumnHeader.Cells(1,4).Text = "3rd Quarter"
fpSpread1.Sheets(0).ColumnHeader.Cells(1,6).Text = "4th Quarter"
’ Set the row header so that the label displays.
fpSpread1.Sheets(0).RowHeader.Columns(0).Width = 45
fpSpread1.Sheets(0).RowHeader.Cells(0,0).Text = "Branch #"
```

## Using the Spread Designer

1. Select the sheet tab for the sheet for which you want to display multiple header rows or columns.
2. In the properties list, in the **Appearance** category, double-click the **ColumnHeader** or **RowHeader** property to display the properties for the column or row header.
3. Set the **RowCount** property to the number or rows you want in the column header or the **ColumnCount** property to the number of columns you want in the row header.
4. From the **File** menu choose **Apply and Exit** to apply your changes to the component and exit Spread Designer.

## See Also

[Headers](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-header)
[Understanding Headers](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-header/spwin-headerparts)
[Showing or Hiding Headers](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-header/spwin-headerhide)
[Setting the Height or Width of Header](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-header/spwin-headersize)
[Setting the Header Text](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-header/spwin-headertext)
[Customizing the Appearance of Headers](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-header/spwin-appearheader)
[Creating a Span in a Header](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-header/spwin-headerspan)
[Customizing the Sheet Corner Appearance](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-header/spwin-sheetcorner)