Excel.ConditionalTextComparisonRule interface

表示单元格值条件格式规则Represents a Cell Value Conditional Format Rule

[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 ]

text

条件格式的文本值。The Text value of conditional format.

[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 ]

operator: Excel.ConditionalTextOperator | "Invalid" | "Contains" | "NotContains" | "BeginsWith" | "EndsWith";

属性值

Excel.ConditionalTextOperator | "Invalid" | "Contains" | "NotContains" | "BeginsWith" | "EndsWith"

text

条件格式的文本值。The Text value of conditional format.

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

text: string;

属性值

string

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Sample");
    const range = sheet.getRange("B16:D18");
    const conditionalFormat = range.conditionalFormats
        .add(Excel.ConditionalFormatType.containsText);
    conditionalFormat.textComparison.format.font.color = "red";
    conditionalFormat.textComparison.rule = { operator: Excel.ConditionalTextOperator.contains, text: "Delayed" };

    await context.sync();
});