Skip to main content
A newer version of this page is available. .

How to: Configure Cell Font Settings

  • 2 minutes to read

To set different font attributes for cells, use the properties of the SpreadsheetFont object.

To access this object for modifying the font of an individual cell, use the Cell object’s Formatting.Font property that is inherited form the Formatting interface.

To change font characteristics for a range of cells, call the CellRange.BeginUpdateFormatting method for this range, use the Font property of the returned Formatting object to access and modify the SpreadsheetFont object and call the CellRange.EndUpdateFormatting method to finalize the modification.

The SpreadsheetFont object provides the following properties to change cell font attributes.

To share font settings with multiple cells in a single step, create or modify the style with the Formatting.Font property specified as required, and assign this style to CellRange.Style for the desired cells.

The following example demonstrates how to specify cell font characteristics (font name, size, color, and style).

View Example

// Access the Font object.
SpreadsheetFont cellFont = worksheet.Cells["A1"].Font;
// Set the font name.
cellFont.Name = "Times New Roman";
// Set the font size.
cellFont.Size = 14;
// Set the font color.
cellFont.Color = Color.Blue;
// Format text as bold.
cellFont.Bold = true;
// Set font to be underlined.
cellFont.UnderlineType = UnderlineType.Single;

The image below shows the specified cell font.

SpreadsheetControl_FontSettings