ExcelScript.ConditionalRangeFont interface

This object represents the font attributes (font style, color, etc.) for an 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 font formats.

getBold()

Specifies if the font is bold.

getColor()

HTML color code representation of the text color (e.g., #FF0000 represents Red).

getItalic()

Specifies if the font is italic.

getStrikethrough()

Specifies the strikethrough status of the font.

getUnderline()

The type of underline applied to the font. See ExcelScript.ConditionalRangeFontUnderlineStyle for details.

setBold(bold)

Specifies if the font is bold.

setColor(color)

HTML color code representation of the text color (e.g., #FF0000 represents Red).

setItalic(italic)

Specifies if the font is italic.

setStrikethrough(strikethrough)

Specifies the strikethrough status of the font.

setUnderline(underline)

The type of underline applied to the font. See ExcelScript.ConditionalRangeFontUnderlineStyle for details.

Method Details

clear()

Resets the font formats.

clear(): void;

Returns

void

getBold()

Specifies if the font is bold.

getBold(): boolean;

Returns

boolean

getColor()

HTML color code representation of the text color (e.g., #FF0000 represents Red).

getColor(): string;

Returns

string

getItalic()

Specifies if the font is italic.

getItalic(): boolean;

Returns

boolean

getStrikethrough()

Specifies the strikethrough status of the font.

getStrikethrough(): boolean;

Returns

boolean

getUnderline()

The type of underline applied to the font. See ExcelScript.ConditionalRangeFontUnderlineStyle for details.

getUnderline(): ConditionalRangeFontUnderlineStyle;

Returns

setBold(bold)

Specifies if the font is bold.

setBold(bold: boolean): void;

Parameters

bold

boolean

Returns

void

setColor(color)

HTML color code representation of the text color (e.g., #FF0000 represents Red).

setColor(color: string): void;

Parameters

color

string

Returns

void

setItalic(italic)

Specifies if the font is italic.

setItalic(italic: boolean): void;

Parameters

italic

boolean

Returns

void

setStrikethrough(strikethrough)

Specifies the strikethrough status of the font.

setStrikethrough(strikethrough: boolean): void;

Parameters

strikethrough

boolean

Returns

void

setUnderline(underline)

The type of underline applied to the font. See ExcelScript.ConditionalRangeFontUnderlineStyle for details.

setUnderline(underline: ConditionalRangeFontUnderlineStyle): void;

Parameters

Returns

void