A newer version of this page is available. Switch to the current version.

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 Range.BeginUpdateFormatting method for this range, use the Font property of the returned Formatting object to access and modify the SpreadsheetFont object and call the Range.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 Range.Style for the desired cells.

This example demonstrates how to format cell font characteristics (e.g., font name, size, color, style) by modifying the SpreadsheetFont object accessed via the Formatting.Font property of the Cell object.

// 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.