ExcelScript.ConditionalRangeFill interface

表示条件范围对象的背景。

注解

示例

/**
 * 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);
}

方法

clear()

重置填充。

getColor()

表示填充颜色的 HTML 颜色代码,格式 #RRGGBB (例如“FFA500”) 或命名 HTML 颜色 (,例如“橙色”) 。

setColor(color)

表示填充颜色的 HTML 颜色代码,格式 #RRGGBB (例如“FFA500”) 或命名 HTML 颜色 (,例如“橙色”) 。

方法详细信息

clear()

重置填充。

clear(): void;

返回

void

getColor()

表示填充颜色的 HTML 颜色代码,格式 #RRGGBB (例如“FFA500”) 或命名 HTML 颜色 (,例如“橙色”) 。

getColor(): string;

返回

string

setColor(color)

表示填充颜色的 HTML 颜色代码,格式 #RRGGBB (例如“FFA500”) 或命名 HTML 颜色 (,例如“橙色”) 。

setColor(color: string): void;

参数

color

string

返回

void