Excel.ConditionalIconCriterion interface

Représente un critère d’icône qui contient un type, une valeur, un opérateur et une icône personnalisée facultative, si aucun jeu d’icônes n’est utilisé.

Propriétés

customIcon

L’icône personnalisée pour le critère actuel, si elle diffère du jeu d’icônes par défaut, null sinon sera renvoyée.

formula

Un nombre ou une formule en fonction du type.

operator

greaterThan ou greaterThanOrEqual pour chacun des types de règles pour la mise en forme conditionnelle d’icône.

type

Ce sur quoi la formule conditionnelle de l’icône doit être basée.

Détails de la propriété

customIcon

L’icône personnalisée pour le critère actuel, si elle diffère du jeu d’icônes par défaut, null sinon sera renvoyée.

customIcon?: Excel.Icon;

Valeur de propriété

Remarques

Jeu d’API : ExcelApi 1.6

formula

Un nombre ou une formule en fonction du type.

formula: string;

Valeur de propriété

string

Remarques

Jeu d’API : ExcelApi 1.6

Exemples

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml

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 the following object shows, because every
        cell that does not match the other two criteria always gets the low
        icon.            
    */
    
    const lowIcon: Excel.Icon = {
        set: Excel.IconSet.threeFlags,
        index: 0
    };

    iconSetCF.criteria = [
        {
            customIcon: lowIcon
        } as Excel.ConditionalIconCriterion,
        {
            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 ou greaterThanOrEqual pour chacun des types de règles pour la mise en forme conditionnelle d’icône.

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

Valeur de propriété

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

Remarques

Jeu d’API : ExcelApi 1.6

Exemples

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml

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 the following object shows, because every
        cell that does not match the other two criteria always gets the low
        icon.            
    */
    
    const lowIcon: Excel.Icon = {
        set: Excel.IconSet.threeFlags,
        index: 0
    };

    iconSetCF.criteria = [
        {
            customIcon: lowIcon
        } as Excel.ConditionalIconCriterion,
        {
            type: Excel.ConditionalFormatIconRuleType.number,
            operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual,
            formula: "=700"
        },
        {
            type: Excel.ConditionalFormatIconRuleType.number,
            operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual,
            formula: "=1000",
        }
    ];
    await context.sync();
});

type

Ce sur quoi la formule conditionnelle de l’icône doit être basée.

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

Valeur de propriété

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

Remarques

Jeu d’API : ExcelApi 1.6

Exemples

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml

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 the following object shows, because every
        cell that does not match the other two criteria always gets the low
        icon.            
    */
    
    const lowIcon: Excel.Icon = {
        set: Excel.IconSet.threeFlags,
        index: 0
    };

    iconSetCF.criteria = [
        {
            customIcon: lowIcon
        } as Excel.ConditionalIconCriterion,
        {
            type: Excel.ConditionalFormatIconRuleType.number,
            operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual,
            formula: "=700"
        },
        {
            type: Excel.ConditionalFormatIconRuleType.number,
            operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual,
            formula: "=1000",
        }
    ];
    await context.sync();
});