ExcelScript.CellValueConditionalFormat interface

セル値の条件付き書式を表します。

注釈

/**
 * This script applies conditional formatting to a range.
 * That formatting is conditional upon the cell's numerical value.
 * Any value between 50 and 75 will have the cell fill color changed and the font made italic.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the range to format.
  const sheet = workbook.getActiveWorksheet();
  const ratingColumn = sheet.getRange("D2:D20");

  // Add cell value conditional formatting.
  const cellValueConditionalFormatting : ExcelScript.CellValueConditionalFormat 
    = ratingColumn.addConditionalFormat(ExcelScript.ConditionalFormatType.cellValue).getCellValue();
  
  // Create the condition, in this case when the cell value is between 50 and 75.
  let rule: ExcelScript.ConditionalCellValueRule = {
    formula1: "50",
    formula2: "75",
    operator: ExcelScript.ConditionalCellValueOperator.between
  };
  cellValueConditionalFormatting.setRule(rule);

  // Set the format to apply when the condition is met.
  let format = cellValueConditionalFormatting.getFormat();
  format.getFill().setColor("yellow");
  format.getFont().setItalic(true);
}

メソッド

getFormat()

条件付き書式フォント、塗りつぶし、罫線、およびその他のプロパティをカプセル化して、書式オブジェクトを返します。

getRule()

この条件付き形式のルール オブジェクトを指定します。

setRule(rule)

この条件付き形式のルール オブジェクトを指定します。

メソッドの詳細

getFormat()

条件付き書式フォント、塗りつぶし、罫線、およびその他のプロパティをカプセル化して、書式オブジェクトを返します。

getFormat(): ConditionalRangeFormat;

戻り値

getRule()

この条件付き形式のルール オブジェクトを指定します。

getRule(): ConditionalCellValueRule;

戻り値

setRule(rule)

この条件付き形式のルール オブジェクトを指定します。

setRule(rule: ConditionalCellValueRule): void;

パラメーター

戻り値

void