How To: Change Table Color

  • 2 minutes to read

The following example illustrates how to set the color of different table elements.

To achieve the required result, the following properties can be used:

The first two properties apply color settings to a single cell. To set them to the whole table, use the Table.ForEachCell method. It requires a delegate to execute in each cell of a table. The delegate is represented by the TableCellProcessorDelegate object.


A complete sample project is available at

// Create a table.
Table table = document.Tables.Create(document.Range.Start, 3, 5, AutoFitBehaviorType.AutoFitToWindow);
// Provide the space between table cells.
//The distance between cells will be 4 mm.
document.Unit = DevExpress.Office.DocumentUnit.Millimeter;
table.TableCellSpacing = 2;
// Change the color of empty space between cells.
table.TableBackgroundColor = Color.Violet;
//Change cell background color.
table.ForEachCell(new TableCellProcessorDelegate(TableHelper.ChangeCellColor));
table.ForEachCell(new TableCellProcessorDelegate(TableHelper.ChangeCellBorderColor));