ExcelScript.ConditionalRangeFormat 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();
  format.getFill().setColor("yellow");
  format.getFont().setItalic(true);
}

方法

getBorders()

应用于整体条件格式范围的边框对象的集合。

getConditionalRangeBorder(index)

使用其名称获取 border 对象

getConditionalRangeBorderBottom()

获取下边框。

getConditionalRangeBorderLeft()

获取左边框。

getConditionalRangeBorderRight()

获取右边框。

getConditionalRangeBorderTop()

获取上边框。

getFill()

返回在总体条件格式范围上定义的填充对象。

getFont()

返回在总体条件格式范围上定义的字体对象。

getNumberFormat()

表示给定区域的 Excel 数字格式代码。 如果 null 传入 ,则清除。

setNumberFormat(numberFormat)

表示给定区域的 Excel 数字格式代码。 如果 null 传入 ,则清除。

方法详细信息

getBorders()

应用于整体条件格式范围的边框对象的集合。

getBorders(): ConditionalRangeBorder[];

返回

getConditionalRangeBorder(index)

使用其名称获取 border 对象

getConditionalRangeBorder(
            index: ConditionalRangeBorderIndex
        ): ConditionalRangeBorder;

参数

index
ExcelScript.ConditionalRangeBorderIndex

要检索的 border 对象的索引值。 有关详细信息,请参阅 ExcelScript.ConditionalRangeBorderIndex

返回

getConditionalRangeBorderBottom()

获取下边框。

getConditionalRangeBorderBottom(): ConditionalRangeBorder;

返回

getConditionalRangeBorderLeft()

获取左边框。

getConditionalRangeBorderLeft(): ConditionalRangeBorder;

返回

getConditionalRangeBorderRight()

获取右边框。

getConditionalRangeBorderRight(): ConditionalRangeBorder;

返回

getConditionalRangeBorderTop()

获取上边框。

getConditionalRangeBorderTop(): ConditionalRangeBorder;

返回

getFill()

返回在总体条件格式范围上定义的填充对象。

getFill(): ConditionalRangeFill;

返回

getFont()

返回在总体条件格式范围上定义的字体对象。

getFont(): ConditionalRangeFont;

返回

getNumberFormat()

表示给定区域的 Excel 数字格式代码。 如果 null 传入 ,则清除。

getNumberFormat(): string;

返回

string

setNumberFormat(numberFormat)

表示给定区域的 Excel 数字格式代码。 如果 null 传入 ,则清除。

setNumberFormat(numberFormat: string): void;

参数

numberFormat

string

返回

void