Home     Products      Support      Corporate     Sign In 

Support Knowledge Base, Article 1205

Product
ExcelWriter
Version
6.x
Title
Excel's color palette explained
Problem

Excel's color palette contains 56 colors, all of which can be accessed and most of which can be replaced using ExcelWriter (v6 or later, .NET or Java). This article will describe the layout of the palette and enumerate the default palette colors.

Solution

The palette is split up into a few different sections:

  • 40 Standard colors, which includes 8 system colors
  • 8 Chart fill colors
  • 8 Chart line colors

The 40 standard colors are available in all color selection dialogs in Excel, including the drop-down dialogs on the Formatting toolbar. In ExcelWriter, they can all be accessed through the Palette class's "get" methods. The system colors can also be accessed through the Palette.SystemColor enumeration. For example:


//--- Get black using the SystemColor enumeration
Color black = Palette.SystemColor.Black;

Chart Fills and Chart Lines are what Excel uses when automatically setting fill and line colors on charts. Chart fills and lines not limited to these colors however. These colors are available as options in Patterns and Chart color dialogs (i.e. Format > Cells > Patterns). In ExcelWriter, all Chart fill and line colors can be accessed and replaced using the Palette's "get" and "set" methods.

All standard and chart colors can be replaced with other colors using the Palette class's "set" methods except for the system colors. For example:


//--- Replace color at index 4 with RGB values (162, 221, 138)
wb.Palette.SetColorAt(4, 162, 221, 138);

This would be equivalent to changing the color palette in Excel through Tools > Options > Color.

Palette Color Reference Charts

Provided below are two views of the default palette. The first is ordered by palette index, and the second is similar to how the palette is displayed from within Excel.

The colors in order of palette index

The palette index is the same index that is used from ExcelWriter to access a specific color in the palette, for example:


//--- Get the color at palette index 9
Color darkGreen = wb.Palette.GetColorAt(9);

The RGB and HEX equivalents of each color are provided.

Palette Index Color RGB HEX System Color
0   0, 0, 0 #000000 Black
1   255, 255, 255 #FFFFFF White
2   255, 0, 0 #FF0000 Red
3   0, 255, 0 #00FF00 Green
4   0, 0, 255 #0000FF Blue
5   255, 255, 0 #FFFF00 Yellow
6   255, 0, 255 #FF00FF Magenta
7   0, 255, 255 #00FFFF Cyan
8   128, 0, 0 #800000  
9   0, 128, 0 #008000  
10   0, 0, 128 #000080  
11   128, 128, 0 #808000  
12   128, 0, 128 #800080  
13   0, 128, 128 #008080  
14   192, 192, 192 #C0C0C0  
15   128, 128, 128 #808080  
16   153, 153, 255 #9999FF Chart Fills
17   153, 51, 102 #993366
18   255, 255, 204 #FFFFCC
19   204, 255, 255 #CCFFFF
20   102, 0, 102 #660066
21   255, 128, 128 #FF8080
22   0, 102, 204 #0066CC
23   204, 204, 255 #CCCCFF
24   0, 0, 128 #000080 Chart Lines
25   255, 0, 255 #FF00FF
26   255, 255, 0 #FFFF00
27   0, 255, 255 #00FFFF
28   128, 0, 128 #800080
29   128, 0, 0 #800000
30   0, 128, 128 #008080
31   0, 0, 255 #0000FF
32   0, 204, 255 #00CCFF  
33   204, 255, 255 #CCFFFF  
34   204, 255, 204 #CCFFCC  
35   255, 255, 153 #FFFF99  
36   153, 204, 255 #99CCFF  
37   255, 153, 204 #FF99CC  
38   204, 153, 255 #CC99FF  
39   255, 204, 153 #FFCC99  
40   51, 102, 255 #3366FF  
41   51, 204, 204 #33CCCC  
42   153, 204, 0 #99CC00  
43   255, 204, 0 #FFCC00  
44   255, 153, 0 #FF9900  
45   255, 102, 0 #FF6600  
46   102, 102, 153 #666699  
47   150, 150, 150 #969696  
48   0, 51, 102 #003300  
49   51, 153, 102 #339966  
50   0, 51, 0 #003300  
51   51, 51, 0 #333300  
52   153, 51, 0 #993300  
53   153, 51, 102 #993366  
54   51, 51, 153 #333399  
55   51, 51, 51 #333333  

The colors as displayed in Excel

The following is similar to how the palette is displayed in Excel. To find the RGB and HEX equivalents, simply match up the palette index to the chart above.

Excel Palette / Palette Indexes
Standard Colors                
0 52 51 50 48 10 54 55
 
               
8 45 11 9 13 4 46 15
 
               
2 44 42 49 41 40 12 47
 
               
6 43 5 3 7 32 53 14
 
               
37 39 35 34 33 36 38 1
 
Chart Fills                
16 17 18 19 20 21 22 23
 
Chart Lines                
24 25 26 27 28 29 30 31
 

Note: When accessing the palette through VBA, the color indexes are 1-based, not 0-based as they are when using ExcelWriter. Therefore, when using VBA, simply add 1 to the indexes listed above.

Excel version of this information

An Excel file containing similar information about default palette colors is attached to this article. You may find it useful for testing different effects on the palette when changing colors using ExcelWriter.

Related links

ExcelWriter Windows Documentation - The Color Palette In Depth
http://docs.softartisans.com/OfficeWriterWindows/3.5.3/ExcelWriter/features/color_palette.aspx

ExcelWriter Windows Documentation - The Palette Class API Reference
http://docs.softartisans.com/OfficeWriterWindows/3.5.3/ExcelWriter/reference/Palette.aspx

Attachments
Attachments/KB1205_files1.zip
Created : 7/20/2006 3:46:50 PM (last modified : 7/26/2006 11:23:16 AM)

Rate this article!

 
Comments



Copyright 2010 © SoftArtisans, Inc. All Rights Reserved.

Site Map     |     Privacy Policy     |     Contact Us