<!-- Generated by tools/SharpCell.Docs from the XML documentation comments. Do not edit; run the tool with 'generate'. -->

# CellStyle

```csharp
public sealed class CellStyle
```

Namespace `SharpCell` · package `SharpCell`

How a cell looks in Excel: font, fill, borders, alignment and protection (locked, formula hidden). The number format is not part of it; see [Cell.NumberFormat](SharpCell.Cell.md#numberformat). Styles play no part in calculation. A record: styles compare by value, and `with` makes a changed copy, such as `style with { Fill = CellColor.FromRgb(0xFFFF00) }`.

## Constructors

<a id="ctor"></a>
### CellStyle()

```csharp
public CellStyle()
```

A style like [CellStyle.Default](SharpCell.CellStyle.md#default); set properties in an initializer.

## Properties

<a id="bottomborder"></a>
### BottomBorder

```csharp
public CellBorder? BottomBorder { get; init; }
```

The bottom edge of the border; null for none.

<a id="default"></a>
### Default

```csharp
public static CellStyle Default { get; }
```

The style of a new workbook's cells: [CellFont.Default](SharpCell.CellFont.md#default), no fill, no borders, General alignment at the bottom.

<a id="fill"></a>
### Fill

```csharp
public CellColor? Fill { get; init; }
```

The colour the cell is filled with; null for none. Only solid fills are read from files.

<a id="font"></a>
### Font

```csharp
public CellFont Font { get; init; }
```

The font.

<a id="formulahidden"></a>
### FormulaHidden

```csharp
public bool FormulaHidden { get; init; }
```

Whether the cell's formula is hidden from the formula bar while its sheet is protected.

<a id="horizontalalignment"></a>
### HorizontalAlignment

```csharp
public CellHorizontalAlignment HorizontalAlignment { get; init; }
```

Where the text sits across the cell. [CellHorizontalAlignment.General](SharpCell.CellHorizontalAlignment.md#general) is Excel's default: numbers right, text left, logical values and errors in the middle.

<a id="indent"></a>
### Indent

```csharp
public int Indent { get; init; }
```

The indent, in steps of the width of three characters of the default font; 0 to 250.

**Exceptions**

- `ArgumentOutOfRangeException`: The indent is outside 0 to 250.

<a id="leftborder"></a>
### LeftBorder

```csharp
public CellBorder? LeftBorder { get; init; }
```

The left edge of the border; null for none.

<a id="locked"></a>
### Locked

```csharp
public bool Locked { get; init; }
```

Whether the cell is locked: it cannot be changed while its sheet is protected (see [Worksheet.Protect](SharpCell.Worksheet.md#protect-string-sheetprotection)). Excel's default is true; set false for input cells.

<a id="rightborder"></a>
### RightBorder

```csharp
public CellBorder? RightBorder { get; init; }
```

The right edge of the border; null for none.

<a id="topborder"></a>
### TopBorder

```csharp
public CellBorder? TopBorder { get; init; }
```

The top edge of the border; null for none.

<a id="verticalalignment"></a>
### VerticalAlignment

```csharp
public CellVerticalAlignment VerticalAlignment { get; init; }
```

Where the text sits from top to bottom of the cell; Excel's default is the bottom.

<a id="wraptext"></a>
### WrapText

```csharp
public bool WrapText { get; init; }
```

Whether text wraps onto more lines inside the cell.
