Excel.ConditionalFormatPresetCriterion enum

Représente les critères du type de format conditionnel des critères prédéfinis.

Remarques

[ Ensemble 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-advanced.yaml

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Sample");
    queueCommandsToClearAllConditionalFormats(sheet);

    const temperatureDataRange = sheet.tables.getItem("TemperatureTable").getDataBodyRange();

    /* When the priority property of ConditionalFormat objects 
       is not explicitly set, they are prioritized in the order
       that they are added, with zero-based numbering: 0, 1, ...
       Contradictions are resolved in favor of the format with
       the lower priority number. In the example below, negative
       numbers will get a green background, but NOT a blue font,
       because priority goes to the format that gives them a red font.
    */

    // Set low numbers to bold, dark red font. This format will
    // get priority 0.
    const presetFormat = temperatureDataRange.conditionalFormats
        .add(Excel.ConditionalFormatType.presetCriteria);
    presetFormat.preset.format.font.color = "red";
    presetFormat.preset.format.font.bold = true;
    presetFormat.preset.rule = { criterion: Excel.ConditionalFormatPresetCriterion.oneStdDevBelowAverage };

     // Set negative numbers to blue font with green background. 
     // This format will get priority 1.
    const cellValueFormat = temperatureDataRange.conditionalFormats
        .add(Excel.ConditionalFormatType.cellValue);
    cellValueFormat.cellValue.format.font.color = "blue";
    cellValueFormat.cellValue.format.fill.color = "lightgreen";
    cellValueFormat.cellValue.rule = { formula1: "=0", operator: "LessThan" };

    await context.sync();
});

Champs

aboveAverage = "AboveAverage"
belowAverage = "BelowAverage"
blanks = "Blanks"
duplicateValues = "DuplicateValues"
equalOrAboveAverage = "EqualOrAboveAverage"
equalOrBelowAverage = "EqualOrBelowAverage"
errors = "Errors"
invalid = "Invalid"
lastMonth = "LastMonth"
lastSevenDays = "LastSevenDays"
lastWeek = "LastWeek"
nextMonth = "NextMonth"
nextWeek = "NextWeek"
nonBlanks = "NonBlanks"
nonErrors = "NonErrors"
oneStdDevAboveAverage = "OneStdDevAboveAverage"
oneStdDevBelowAverage = "OneStdDevBelowAverage"
thisMonth = "ThisMonth"
thisWeek = "ThisWeek"
threeStdDevAboveAverage = "ThreeStdDevAboveAverage"
threeStdDevBelowAverage = "ThreeStdDevBelowAverage"
today = "Today"
tomorrow = "Tomorrow"
twoStdDevAboveAverage = "TwoStdDevAboveAverage"
twoStdDevBelowAverage = "TwoStdDevBelowAverage"
uniqueValues = "UniqueValues"
yesterday = "Yesterday"