Share via


ExcelScript.TextConditionalFormat interface

Représente un format conditionnel de texte spécifique.

Remarques

Exemples

/**
 * This script adds conditional formatting to the first column in the worksheet.
 * This formatting gives the cells a green fill if they have text starting with "Excel".
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the first column in the current worksheet.
  const currentSheet = workbook.getActiveWorksheet();
  const firstColumn = currentSheet.getRange("A:A");

  // Add conditional formatting based on the text in the cells.
  const textConditionFormat: ExcelScript.TextConditionalFormat = 
    firstColumn.addConditionalFormat(ExcelScript.ConditionalFormatType.containsText).getTextComparison();

  // Set the conditional format to provide a green fill.
  textConditionFormat.getFormat().getFill().setColor("green");

  // Apply the condition rule that the text begins with "Excel".
  const textRule: ExcelScript.ConditionalTextComparisonRule = {
    operator: ExcelScript.ConditionalTextOperator.beginsWith,
    text: "Excel"
  };
  textConditionFormat.setRule(textRule);
}

Méthodes

getFormat()

Renvoie un objet de format, encapsulant la police, le remplissage, les bordures et d’autres propriétés du format conditionnel.

getRule()

Règle de mise en forme conditionnelle.

setRule(rule)

Règle de mise en forme conditionnelle.

Détails de la méthode

getFormat()

Renvoie un objet de format, encapsulant la police, le remplissage, les bordures et d’autres propriétés du format conditionnel.

getFormat(): ConditionalRangeFormat;

Retours

getRule()

Règle de mise en forme conditionnelle.

getRule(): ConditionalTextComparisonRule;

Retours

setRule(rule)

Règle de mise en forme conditionnelle.

setRule(rule: ConditionalTextComparisonRule): void;

Paramètres

Retours

void