Skip to main content

How to: Change Cell Font and Background Color

  • 2 minutes to read

You can change the font and background colors of a cell.

To specify these attributes for an individual cell, modify the Formatting.Font and Formatting.Fill properties of the Cell object. These properties are inherited from the Formatting interface.

To change the color characteristics for a range of cells, call the CellRange.BeginUpdateFormatting method for this range, modify the Font and Fill properties of the returned Formatting object, and call the CellRange.EndUpdateFormatting method to finalize the modification.

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


Set the BackgroundColor property to Empty or Transparent to clear the cell background.

The following example specifies font and background colors for an individual cell and cell range:

View Example: WinForms Spreadsheet API

using DevExpress.Spreadsheet;
using System.Drawing;
// ...

// Format an individual cell.
worksheet.Cells["A1"].Font.Color = Color.Red;
worksheet.Cells["A1"].FillColor = Color.Yellow;

// Format a cell range.
CellRange range = worksheet.Range["C3:H10"];
Formatting rangeFormatting = range.BeginUpdateFormatting();
rangeFormatting.Font.Color = Color.Blue;
rangeFormatting.Fill.BackgroundColor = Color.LightBlue;
rangeFormatting.Fill.PatternType = PatternType.LightHorizontal;
rangeFormatting.Fill.PatternColor = Color.Violet;

The image below shows the results.