ExcelScript.CalculationState enum
表示整个 Excel 应用程序的计算状态。
注解
示例
/**
* 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;
}
}
字段
calculating | 正在进行计算。 |
done | 计算完成。 |
pending | 已进行会触发计算的更改,但还未执行重新计算。 |