CellStyle
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. 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
CellStyle()
public CellStyle()
A style like CellStyle.Default; set properties in an initializer.
Properties
BottomBorder
public CellBorder? BottomBorder { get; init; }
The bottom edge of the border; null for none.
Default
public static CellStyle Default { get; }
The style of a new workbook's cells: CellFont.Default, no fill, no borders, General alignment at the bottom.
Fill
public CellColor? Fill { get; init; }
The colour the cell is filled with; null for none. Only solid fills are read from files.
Font
public CellFont Font { get; init; }
The font.
FormulaHidden
public bool FormulaHidden { get; init; }
Whether the cell's formula is hidden from the formula bar while its sheet is protected.
HorizontalAlignment
public CellHorizontalAlignment HorizontalAlignment { get; init; }
Where the text sits across the cell. CellHorizontalAlignment.General is Excel's default: numbers right, text left, logical values and errors in the middle.
Indent
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.
LeftBorder
public CellBorder? LeftBorder { get; init; }
The left edge of the border; null for none.
Locked
public bool Locked { get; init; }
Whether the cell is locked: it cannot be changed while its sheet is protected (see Worksheet.Protect). Excel's default is true; set false for input cells.
RightBorder
public CellBorder? RightBorder { get; init; }
The right edge of the border; null for none.
TopBorder
public CellBorder? TopBorder { get; init; }
The top edge of the border; null for none.
VerticalAlignment
public CellVerticalAlignment VerticalAlignment { get; init; }
Where the text sits from top to bottom of the cell; Excel's default is the bottom.
WrapText
public bool WrapText { get; init; }
Whether text wraps onto more lines inside the cell.