Compartilhar via


ExcelScript.CustomConditionalFormat interface

Representa um tipo de formato condicional personalizado.

Comentários

Exemplos

/**
 * This script applies a custom three-color conditional formatting to the selected range.
 * The three colors represent positive, negative, or no changes from the values in the previous column.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the selected cells.
  let selectedRange = workbook.getSelectedRange();

  // Apply a rule for positive change from the previous column.
  let positiveChange: ExcelScript.ConditionalFormat = selectedRange.addConditionalFormat(ExcelScript.ConditionalFormatType.custom);
  let positiveCustom: ExcelScript.CustomConditionalFormat = positiveChange.getCustom();
  positiveCustom.getFormat().getFill().setColor("lightgreen");
  positiveCustom.getRule().setFormula(`=${selectedRange.getCell(0, 0).getAddress()}>${selectedRange.getOffsetRange(0, -1).getCell(0, 0).getAddress()}`);

  // Apply a rule for negative change from the previous column.
  let negativeChange: ExcelScript.ConditionalFormat = selectedRange.addConditionalFormat(ExcelScript.ConditionalFormatType.custom);
  let negativeCustom: ExcelScript.CustomConditionalFormat = negativeChange.getCustom();
  negativeCustom.getFormat().getFill().setColor("pink");
  negativeCustom.getRule().setFormula(`=${selectedRange.getCell(0, 0).getAddress()}<${selectedRange.getOffsetRange(0, -1).getCell(0, 0).getAddress()}`);

  // Apply a rule for no change from the previous column.
  let sameChange: ExcelScript.ConditionalFormat = selectedRange.addConditionalFormat(ExcelScript.ConditionalFormatType.custom);
  let sameCustom: ExcelScript.CustomConditionalFormat = sameChange.getCustom();
  sameCustom.getFormat().getFill().setColor("lightyellow");
  sameCustom.getRule().setFormula(`=${selectedRange.getCell(0, 0).getAddress()}=${selectedRange.getOffsetRange(0, -1).getCell(0, 0).getAddress()}`);
}

Métodos

getFormat()

Devolve um objeto de formatação, encapsulando o tipo de letra, preenchimento, limites e outras propriedades dos formatos condicionais.

getRule()

Especifica o Rule objeto neste formato condicional.

Detalhes do método

getFormat()

Devolve um objeto de formatação, encapsulando o tipo de letra, preenchimento, limites e outras propriedades dos formatos condicionais.

getFormat(): ConditionalRangeFormat;

Retornos

getRule()

Especifica o Rule objeto neste formato condicional.

getRule(): ConditionalFormatRule;

Retornos