ExcelScript.ConditionalRangeFill interface

Represents the background of a conditional range object.

Remarks

Examples

/**
 * This script applies cell value conditional formatting to a range.
 * Any value less than 60 will have the cell's fill color changed and the font made italic.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the range to format.
  const selectedRange = workbook.getSelectedRange();

  // Add cell value conditional formatting.
  const cellValueConditionalFormatting =
    selectedRange.addConditionalFormat(ExcelScript.ConditionalFormatType.cellValue).getCellValue();

  // Create the condition, in this case when the cell value is less than 60.
  const rule: ExcelScript.ConditionalCellValueRule = {
    formula1: "60",
    operator: ExcelScript.ConditionalCellValueOperator.lessThan
  };
  cellValueConditionalFormatting.setRule(rule);

  // Set the format to apply when the condition is met.
  const format: ExcelScript.ConditionalRangeFormat = cellValueConditionalFormatting.getFormat();
  const fill: ExcelScript.ConditionalRangeFill = format.getFill();
  const font: ExcelScript.ConditionalRangeFont = format.getFont();
  fill.setColor("yellow");
  font.setItalic(true);
}

Methods

clear()

Resets the fill.

getColor()

HTML color code representing the color of the fill, in the form #RRGGBB (e.g., "FFA500") or as a named HTML color (e.g., "orange").

setColor(color)

HTML color code representing the color of the fill, in the form #RRGGBB (e.g., "FFA500") or as a named HTML color (e.g., "orange").

Method Details

clear()

Resets the fill.

clear(): void;

Returns

void

getColor()

HTML color code representing the color of the fill, in the form #RRGGBB (e.g., "FFA500") or as a named HTML color (e.g., "orange").

getColor(): string;

Returns

string

setColor(color)

HTML color code representing the color of the fill, in the form #RRGGBB (e.g., "FFA500") or as a named HTML color (e.g., "orange").

setColor(color: string): void;

Parameters

color

string

Returns

void