# Setting Table Styles

Learn how to add custom or built-in styles to a table and specify styles for specific table areas with TableStyle properties.

## Content

You can add custom or built-in styles to a table.
![Table with a default and custom styles](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/tablestyle.png)
You can specify custom styles for the first, second, or last column as well as other areas of the table. For a complete list, see the [TableStyle](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.TableStyle.html) properties. You can specify a built-in style with the **TableStyle** fields.
Table styles have a priority order when the styles overlap. The priority from highest to lowest is cell, row, column, and table.
Some style properties apply to areas that are not visible or do not have a style setting by default. For example, the **FirstRowStripe** style is not displayed unless the [BandedRows](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.TableView.BandedRows.html) property is true. The following table lists the **TableView** setting that must be true before the associated table style is displayed in the table.

| **TableView property** | **TableStyle property** |
| ------------------ | ------------------- |
| [BandedColumns](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.TableView.BandedColumns.html) | [FirstColumnStripe](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.TableStyle.FirstColumnStripe.html), [FirstColumnStripSize](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.TableStyle.FirstColumnStripSize.html), [SecondColumnStripe](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.TableStyle.SecondColumnStripe.html), [SecondColumnStripSize](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.TableStyle.SecondColumnStripSize.html) |
| [BandedRows](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.TableView.BandedRows.html) | [FirstRowStripe](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.TableStyle.FirstRowStripe.html), [FirstRowStripSize](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.TableStyle.FirstRowStripSize.html), [SecondRowStripe](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.TableStyle.SecondRowStripe.html), [SecondRowStripSize](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.TableStyle.SecondRowStripSize.html) |
| [FirstColumn](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.TableView.FirstColumn.html) | [FirstColumn](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.TableStyle.FirstColumn.html) |
| [HeaderRowVisible](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.TableView.HeaderRowVisible.html) | [HeaderRow](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.TableStyle.HeaderRow.html) |
| [LastColumn](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.TableView.LastColumn.html) | [LastColumn](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.TableStyle.LastColumn.html) |

## Using Code

1. Create a style using [TableBorder](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.TableBorder.html) and [TableElementStyle](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.TableElementStyle.html).
2. Use the [TableStyle](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.TableStyle.-ctor.html) constructor and the [CreateTableStyle](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.FpSpread.CreateTableStyle.html) method to assign the style.
3. Set the **TableStyle** [FirstColumn](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.TableStyle.FirstColumn.html) property to assign the style to the column or set any of the **TableStyle** properties.
4. Set the **TableView** [FirstColumn](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.TableView.FirstColumn.html) property to True to display the column style or set the appropriate **TableView** property.

## Example

This example code adds a custom style to the first column.

```csharp
FarPoint.Win.ComplexBorderSide bside = new FarPoint.Win.ComplexBorderSide(Color.Yellow);
FarPoint.Win.Spread.TableBorder tborder = new FarPoint.Win.Spread.TableBorder(bside);
FarPoint.Win.Spread.TableElementStyle testyle = new FarPoint.Win.Spread.TableElementStyle(tborder, Color.Red, Color.Blue, FarPoint.Win.Spread.RegularBoldItalicFontStyle.Bold);
FarPoint.Win.Spread.TableStyle tstyle = fpSpread1.CreateTableStyle("Style1", FarPoint.Win.Spread.TableStyle.TableStyleLight2);
tstyle.FirstColumn = testyle;
fpSpread1.Sheets[0].Cells[1, 1].Text = "Last Name";
fpSpread1.Sheets[0].Cells[1, 2].Text = "Value";
fpSpread1.Sheets[0].Cells[2, 1].Text = "Smith";
fpSpread1.Sheets[0].Cells[2, 2].Value = 50;
fpSpread1.Sheets[0].Cells[3, 1].Text = "Vil";
fpSpread1.Sheets[0].Cells[3, 2].Value = 10;
fpSpread1.Sheets[0].Cells[4, 1].Text = "Press";
fpSpread1.Sheets[0].Cells[4, 2].Value = 78;
fpSpread1.TableStyleCollection.Add(tstyle);
FarPoint.Win.Spread.TableView table = fpSpread1.Sheets[0].AddTable("table", 1, 1, 5, 2, "Style1");
table.FirstColumn = true;
```

```vbnet
Dim bside As New FarPoint.Win.ComplexBorderSide(Color.Yellow)
Dim tborder As New FarPoint.Win.Spread.TableBorder(bside)
Dim testyle As New FarPoint.Win.Spread.TableElementStyle(tborder, Color.Red, Color.Blue, FarPoint.Win.Spread.RegularBoldItalicFontStyle.Bold)
Dim tstyle As FarPoint.Win.Spread.TableStyle
tstyle = fpSpread1.CreateTableStyle("Style1", FarPoint.Win.Spread.TableStyle.TableStyleLight2)
tstyle.FirstColumn = testyle
pSpread1.Sheets(0).Cells(1, 1).Text = "Last Name"
fpSpread1.Sheets(0).Cells(1, 2).Text = "Value"
fpSpread1.Sheets(0).Cells(2, 1).Text = "Smith"
fpSpread1.Sheets(0).Cells(2, 2).Value = 50
fpSpread1.Sheets(0).Cells(3, 1).Text = "Vil"
fpSpread1.Sheets(0).Cells(3, 2).Value = 10
fpSpread1.Sheets(0).Cells(4, 1).Text = "Press"
fpSpread1.Sheets(0).Cells(4, 2).Value = 78
fpSpread1.TableStyleCollection.Add(tstyle)
Dim table As FarPoint.Win.Spread.TableView = fpSpread1.Sheets(0).AddTable("table", 1, 1, 5, 2, "Style1")
table.FirstColumn = True
```

## See Also

[Tables](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-tables)
[Adding a Table](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-tables/spwin-tableadd)
[Using Table Filters](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-tables/spwin-tablefilter)
[Resizing a Table](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-tables/spwin-tableresize)
[Sorting a Table](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-tables/spwin-tablesort)
[Adding a Table Formula](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-tables/tableformula)
[Understanding Structured References](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-tables/spwin-structref)