ExcelScript.ConditionalTopBottomRule interface

表示顶部/底部条件格式的规则。

注解

示例

/**
 * This sample applies conditional formatting to the currently used range in the worksheet. 
 * The conditional formatting is a pink fill for the 5 lowest values.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the current worksheet.
  let selectedSheet = workbook.getActiveWorksheet();

  // Get the used range in the worksheet.
  let range = selectedSheet.getUsedRange();

  // Set the fill color to pink for the lowest 5 values in the range.
  let conditionalFormat = range.addConditionalFormat(ExcelScript.ConditionalFormatType.topBottom)
  conditionalFormat.getTopBottom().getFormat().getFill().setColor("pink");
  conditionalFormat.getTopBottom().setRule({
    rank: 5, /* The numerical threshold. */
    type: ExcelScript.ConditionalTopBottomCriterionType.bottomItems /* The type of the top/bottom condition. */
  });
}

属性

rank

1 和 1000 之间的数字排名或 1 和 100 之间的百分比排名。

type

根据排名靠前或下一级设置值的格式。

属性详细信息

rank

1 和 1000 之间的数字排名或 1 和 100 之间的百分比排名。

rank: number;

属性值

number

type

根据排名靠前或下一级设置值的格式。

type: ConditionalTopBottomCriterionType;

属性值