Excel.ConditionalIconCriterion interface

表示一个图标条件, 其中包含类型、值、运算符和可选的自定义图标 (如果不使用 iconset)。Represents an Icon Criterion which contains a type, value, an Operator, and an optional custom icon, if not using an iconset.

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

属性

customIcon

如果与默认 IconSet 不同,返回当前条件的自定义图标,否则将返回 null。The custom icon for the current criterion if different from the default IconSet, else null will be returned.

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

formula

取决于类型的数字或公式。A number or a formula depending on the type.

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

operator

图标条件格式的每个规则类型的 GreaterThan 或 GreaterThanOrEqual。GreaterThan or GreaterThanOrEqual for each of the rule type for the Icon conditional format.

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

type

应基于的图标条件公式。What the icon conditional formula should be based on.

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

属性详细信息

customIcon

如果与默认 IconSet 不同,返回当前条件的自定义图标,否则将返回 null。The custom icon for the current criterion if different from the default IconSet, else null will be returned.

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

customIcon?: Excel.Icon;

属性值

formula

取决于类型的数字或公式。A number or a formula depending on the type.

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

formula: string;

属性值

string

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Sample");
    const range = sheet.getRange("B8:E13");
    const conditionalFormat = range.conditionalFormats
        .add(Excel.ConditionalFormatType.iconSet);
    const iconSetCF = conditionalFormat.iconSet;
    iconSetCF.style = Excel.IconSet.threeTriangles;

    /*
        The iconSetCF.criteria array is automatically prepopulated with
        criterion elements whose properties have been given default settings.
        You can't write to each property of a criterion directly. Instead,
        replace the whole criteria object.

        With a "three*" icon set style, such as "threeTriangles", the third
        element in the criteria array (criteria[2]) defines the "top" icon;
        e.g., a green triangle. The second (criteria[1]) defines the "middle"
        icon, The first (criteria[0]) defines the "low" icon, but it
        can often be left empty as this method does below, because every
        cell that does not match the other two criteria always gets the low
        icon.            
    */
    iconSetCF.criteria = [
        {} as any,
        {
            type: Excel.ConditionalFormatIconRuleType.number,
            operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual,
            formula: "=700"
        },
        {
            type: Excel.ConditionalFormatIconRuleType.number,
            operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual,
            formula: "=1000",
        }
    ];

    await context.sync();
});

operator

图标条件格式的每个规则类型的 GreaterThan 或 GreaterThanOrEqual。GreaterThan or GreaterThanOrEqual for each of the rule type for the Icon conditional format.

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

operator: Excel.ConditionalIconCriterionOperator | "Invalid" | "GreaterThan" | "GreaterThanOrEqual";

属性值

Excel.ConditionalIconCriterionOperator | "Invalid" | "GreaterThan" | "GreaterThanOrEqual"

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Sample");
    const range = sheet.getRange("B8:E13");
    const conditionalFormat = range.conditionalFormats
        .add(Excel.ConditionalFormatType.iconSet);
    const iconSetCF = conditionalFormat.iconSet;
    iconSetCF.style = Excel.IconSet.threeTriangles;

    /*
        The iconSetCF.criteria array is automatically prepopulated with
        criterion elements whose properties have been given default settings.
        You can't write to each property of a criterion directly. Instead,
        replace the whole criteria object.

        With a "three*" icon set style, such as "threeTriangles", the third
        element in the criteria array (criteria[2]) defines the "top" icon;
        e.g., a green triangle. The second (criteria[1]) defines the "middle"
        icon, The first (criteria[0]) defines the "low" icon, but it
        can often be left empty as this method does below, because every
        cell that does not match the other two criteria always gets the low
        icon.            
    */
    iconSetCF.criteria = [
        {} as any,
        {
            type: Excel.ConditionalFormatIconRuleType.number,
            operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual,
            formula: "=700"
        },
        {
            type: Excel.ConditionalFormatIconRuleType.number,
            operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual,
            formula: "=1000",
        }
    ];

    await context.sync();
});
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();
});

type

应基于的图标条件公式。What the icon conditional formula should be based on.

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

type: Excel.ConditionalFormatIconRuleType | "Invalid" | "Number" | "Percent" | "Formula" | "Percentile";

属性值

Excel.ConditionalFormatIconRuleType | "Invalid" | "Number" | "Percent" | "Formula" | "Percentile"

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Sample");
    const range = sheet.getRange("B8:E13");
    const conditionalFormat = range.conditionalFormats
        .add(Excel.ConditionalFormatType.iconSet);
    const iconSetCF = conditionalFormat.iconSet;
    iconSetCF.style = Excel.IconSet.threeTriangles;

    /*
        The iconSetCF.criteria array is automatically prepopulated with
        criterion elements whose properties have been given default settings.
        You can't write to each property of a criterion directly. Instead,
        replace the whole criteria object.

        With a "three*" icon set style, such as "threeTriangles", the third
        element in the criteria array (criteria[2]) defines the "top" icon;
        e.g., a green triangle. The second (criteria[1]) defines the "middle"
        icon, The first (criteria[0]) defines the "low" icon, but it
        can often be left empty as this method does below, because every
        cell that does not match the other two criteria always gets the low
        icon.            
    */
    iconSetCF.criteria = [
        {} as any,
        {
            type: Excel.ConditionalFormatIconRuleType.number,
            operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual,
            formula: "=700"
        },
        {
            type: Excel.ConditionalFormatIconRuleType.number,
            operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual,
            formula: "=1000",
        }
    ];

    await context.sync();
});