All docs
V21.2
21.2
21.1
20.2
The page you are viewing does not exist in version 20.2. This link will take you to the root page.
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
Row

WorkbookColorPalette.Item[Int32] Property

Returns or specifies a color in the workbook palette.

Namespace: DevExpress.Spreadsheet

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

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