Object Reference : Object View and Procedure Reference : Table
  
 
setfillcolor
Set the fill (background) color of the specified table cells.
Syntax
table_name.setfillcolor(cell_range, options) color_arg
where cell_range can take one of the following forms:
 
@all
Apply to all cells in the table.
cell
Cell identifier. You can identify cells using either the column letter and row number (e.g., “A1”), or by using “R” followed by the row number followed by “C” and the column number (e.g., “R1C2”).You can optionally add an ‘if’ condition to the identifier. Without the ‘if’ condition, the formatting will be applied to all the identified cells. If an ‘if’ condition is supplied, the formatting will be applied to all the identified where the ‘if’ condition is true. The ‘if’ condition must be followed by a boolean expression.
row[,] col
Row number, followed by column letter or number (e.g., “2,C”, or “2,3”), separated by “,”. Apply to cell.
row
Row number (e.g., “2”). Apply to all cells in the row.
col
Column letter (e.g., “B”). Apply to all cells in the column.
first_cell[:]last_cell, first_cell[,]last_cell
Top left cell of the selection range (specified in “cell” format), followed by bottom right cell of the selection range (specified in “cell” format), separated by a “:” or “,” (e.g., “A2:C10”, “A2,C10”, or “R2C1:R10C3”, “R2C1,R10C3”). Apply to all cells in the rectangular region defined by the first cell and last cell.
first_cell_row[,] first_cell_col[,] last_cell_row[,] last_cell_col
Top left cell of the selection range (specified in “row[,] col” format), followed by bottom right cell of the selection range (specified in “row[,] col” format), separated by a “,” (e.g., “2,A,10,C” or “2,1,10,3”). Apply to all cells in the rectangular region defined by the first cell and last cell.
The color_arg specifies the color to be applied to the text in the cells. The color may be specified using predefined color names, by specifying the individual red-green-blue (RGB) components using the special “@RGB” function, or by specifying the individual red-green-blue (RGB) components in hexadecimal using the special “@HEX” function. The second and third methods are obviously more difficult, but allow you to use custom colors.
The predefined colors are given by the keywords (with their RGB and HEX equivalents):
 
blue
@rgb(0, 0, 255)
@hex(0000ff)
red
@rgb(255, 0, 0)
@hex(ff0000)
ltred
@rgb(255, 168, 168)
@hex(ffa8a8)
green
@rgb(0, 128, 0)
@hex(008000)
black
@rgb(0, 0, 0)
@hex(000000)
white
@rgb(255, 255, 255)
@hex(ffffff)
purple
@rgb(128, 0, 128)
@hex(800080)
orange
@rgb(255, 128, 0)
@hex(ff8000)
yellow
@rgb(255, 255, 0)
@hex(ffff00)
gray
@rgb(128, 128, 128)
@hex(808080)
ltgray
@rgb(192, 192, 192)
@hex(c0c0c0)
Options
 
mode=arg
Color mode: “Alt” (alternate and color every other row in the cell_range); “All” (color every row in the cell_range).
Examples
To set a purple background color for the cell in the second row and third column of TAB1, you may use any of the following:
tab1.setfillcolor(C2) @rgb(128, 0, 128)
tab1.setfillcolor(2,C) @HEX(808080)
tab1.setfillcolor(2,3) purple
tab1.setfillcolor(r2c3) purple
You may also specify a yellow color for the background of an entire column, or an entire row:
tab1.setfillcolor(C) @RGB(255, 255, 0)
tab1.setfillcolor(2) yellow
or for every other row, the background of the cells in a rectangular region:
tab1.setfillcolor(R2C3:R3C6, mode=alt) ltgray
tab1.setfillcolor(2,C,3,F, mode=alt) @rgb(192, 192, 192)
tab1.setfillcolor(2,3,3,6, mode=alt) @hex(c0c0c0)
You may conditionally set the fill color for a range of cells. For example, in the below command cells a3 to a18 will be yellow if the sum from a second range of cells (b4 to b19) added to a third range of cells (c4 to c19) is greater than 0.5. Specifically, cell a3 will be set to yellow if cell b4 plus cell c4 is greater than 0.5:
tab1.setfillcolor(a3:a18 if [b4:b19]+[c4:c19] > .5) yellow
Cross-references
See Table::settextcolor and Table::setfont for details on changing text color and font, and Table::setlines for drawing lines between and through cells.
For additional discussion of table commands see “Working with Tables and Spreadsheets”.
See also “Table and Text Objects” for a discussion and examples of table formatting in EViews.