Skip to main content

How to: Configure Cell Font Settings

  • 2 minutes to read

Use the SpreadsheetFont object’s properties to specify font attributes for worksheet cells and cell ranges.

The Cell.Font property allows you to modify the font for an individual cell.

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

The SpreadsheetFont object contains the following properties used to change cell font attributes:

Create and modify cell styles to apply multiple format attributes to worksheet cells simultaneously.

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.

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 result (the workbook is opened in Microsoft® Excel®).

Spreadsheet_FontSettings

See Also