SetBackgroundColor
Sets the background color to the current table cell.
Syntax
expression.SetBackgroundColor(color);
expression - A variable that represents a ApiTableCell class.
Parameters
| Name | Required/Optional | Data type | Default | Description |
|---|---|---|---|---|
| color | Optional | ApiColor | If not passed, the background color will be cleared. |
Returns
boolean
Example
This example sets the background color to the table cell.
- Code
- Result
// How to color the cell.
// Get the first cell from the table and set its background color.
let doc = Api.GetDocument();
let tableStyle = doc.CreateStyle("CustomTableStyle", "table");
tableStyle.SetBasedOn(doc.GetStyle("Bordered"));
let table = Api.CreateTable(4, 2);
table.SetWidth("percent", 100);
table.SetStyle(tableStyle);
let cell = table.GetRow(0).GetCell(0);
cell.SetBackgroundColor(Api.HexColor('#FF6F3D'));
doc.Push(table);