Skip to main content
All docs
V23.2
Row

WorkbookColorPalette.Item[Int32] Property

Returns or specifies a color in the workbook palette.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v23.2.Core.dll

NuGet Package: DevExpress.Spreadsheet.Core

Declaration

Color this[int index] { get; set; }

Parameters

Name Type Description
index Int32

A zero-based index of the color to return or set. Valid indexes are from 0 to 55.

Property Value

Type Description
Color

The color at the specified index.

Exceptions

Type Description
IndexOutOfRangeException

Occurs if the index value is less than 0 or greater than 55.

ArgumentException

Occurs if you assign an empty, transparent, or semi-transparent color to this property. Only opaque colors are allowed.

Remarks

A workbook palette includes 56 RGB colors. The following image illustrates the default palette colors and their indexes:

Default Workbook Palette

The Item property allows you to change palette colors, as shown in the example below.

using DevExpress.Spreadsheet;
using System.Drawing;
// ...
using (Workbook workbook = new Workbook())
{
    var worksheet = workbook.Worksheets.ActiveWorksheet;
    // Customize palette colors.
    workbook.ColorPalette[1] = Color.FromArgb(0xD9, 0xDD, 0xDC);
    workbook.ColorPalette[2] = Color.FromArgb(0xE0, 0x11, 0x5F);

    // Add a value to the "B2" cell.
    var cellB2 = worksheet["B2"];
    cellB2.Value = "Custom Palette Colors";
    // Use custom palette colors to format the cell.
    cellB2.Font.Color = workbook.ColorPalette[1];
    cellB2.FillColor = workbook.ColorPalette[2];
}

The image below shows the result.

Custom Workbook Palette Colors

Use the WorkbookColorPalette.IsCustom property to check whether the workbook palette was customized. Call the WorkbookColorPalette.Reset method to reset custom palette colors to default colors.

See Also