ExcelScript.CalculationState enum

Represents the state of calculation across the entire Excel application.

Remarks

Examples

/**
 * This script uses the fill color of the first cell to indicate the current
 * calculation state of the workbook.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the first cell in the first worksheet.
  const cell = workbook.getWorksheets()[0].getCell(0,0);

  // Get that cell's fill object.
  const cellFill = cell.getFormat().getFill();

  // Set the cell fill based on the calculation state.
  const calcState = workbook.getApplication().getCalculationState();
  switch (calcState) {
    case ExcelScript.CalculationState.pending:
      cellFill.setColor("Red");
      break;
    case ExcelScript.CalculationState.calculating:
      cellFill.setColor("Yellow");
      break;
    case ExcelScript.CalculationState.done:
      cellFill.setColor("Green");
      break;
  }
}

Fields

calculating

Calculations in progress.

done

Calculations complete.

pending

Changes that trigger calculation have been made, but a recalculation has not yet been performed.