Excel.ConditionalCellValueRule interface

表示单元格值条件格式规则。Represents a cell value conditional format rule.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

属性

formula1

如果需要,公式可对条件格式规则进行求值。The formula, if required, to evaluate the conditional format rule on.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

formula2

如果需要,公式可对条件格式规则进行求值。The formula, if required, to evaluate the conditional format rule on.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

operator

文本条件格式的运算符。The operator of the text conditional format.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

属性详细信息

formula1

如果需要,公式可对条件格式规则进行求值。The formula, if required, to evaluate the conditional format rule on.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

formula1: string;

属性值

string

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Sample");
    const range = sheet.getRange("B21:E23");
    const conditionalFormat = range.conditionalFormats
        .add(Excel.ConditionalFormatType.cellValue);
    conditionalFormat.cellValue.format.font.color = "red";
    conditionalFormat.cellValue.rule = { formula1: "=0", operator: "LessThan" };

    await context.sync();
});

formula2

如果需要,公式可对条件格式规则进行求值。The formula, if required, to evaluate the conditional format rule on.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

formula2?: string;

属性值

string

operator

文本条件格式的运算符。The operator of the text conditional format.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

operator: Excel.ConditionalCellValueOperator | "Invalid" | "Between" | "NotBetween" | "EqualTo" | "NotEqualTo" | "GreaterThan" | "LessThan" | "GreaterThanOrEqual" | "LessThanOrEqual";

属性值

Excel.ConditionalCellValueOperator | "Invalid" | "Between" | "NotBetween" | "EqualTo" | "NotEqualTo" | "GreaterThan" | "LessThan" | "GreaterThanOrEqual" | "LessThanOrEqual"

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Sample");
    const range = sheet.getRange("B21:E23");
    const conditionalFormat = range.conditionalFormats
        .add(Excel.ConditionalFormatType.cellValue);
    conditionalFormat.cellValue.format.font.color = "red";
    conditionalFormat.cellValue.rule = { formula1: "=0", operator: "LessThan" };

    await context.sync();
});