ExcelScript.Application interface

表示用于管理工作簿的 Excel 应用程序。

方法

calculate(calculationType)

重新计算 Excel 中当前打开的所有工作簿。

getCalculationEngineVersion()

返回用于上次完整重新计算的 Excel 计算引擎版本。

getCalculationMode()

返回工作簿中使用的计算模式,由 中的 ExcelScript.CalculationMode常量定义。 可能的值为:Automatic,其中 Excel 控制重新计算;,AutomaticExceptTables其中 Excel 控制重新计算,但忽略表中的更改;Manual其中,计算在用户请求时完成。

getCalculationState()

返回应用程序的计算状态。 有关详细信息,请参阅 ExcelScript.CalculationState

getCultureInfo()

提供基于当前系统区域性设置的信息。 这包括区域性名称、数字格式和其他区域性相关设置。

getDecimalSeparator()

获取用作数值的小数分隔符的字符串。 这基于本地 Excel 设置。

getIterativeCalculation()

返回迭代计算设置。 在 Windows 和 Mac 上的 Excel 中,设置将应用于 Excel 应用程序。 在Excel web 版和其他平台中,这些设置将应用于活动工作簿。

getThousandsSeparator()

获取用于分隔数值的小数点左侧数字组的字符串。 这基于本地 Excel 设置。

getUseSystemSeparators()

指定是否启用 Excel 的系统分隔符。 系统分隔符包括小数分隔符和千位分隔符。

setCalculationMode(calculationMode)

返回工作簿中使用的计算模式,由 中的 ExcelScript.CalculationMode常量定义。 可能的值为:Automatic,其中 Excel 控制重新计算;,AutomaticExceptTables其中 Excel 控制重新计算,但忽略表中的更改;Manual其中,计算在用户请求时完成。

方法详细信息

calculate(calculationType)

重新计算 Excel 中当前打开的所有工作簿。

calculate(calculationType: CalculationType): void;

参数

calculationType
ExcelScript.CalculationType

指定要使用的计算类型。 有关详细信息,请参阅 ExcelScript.CalculationType

返回

void

示例

/**
 * This script fully recalculates the entire workbook.
 * This code is useful when automatic recalculation is turned off
 * but later parts of the script rely on updated values.
 */
function main(workbook: ExcelScript.Workbook, workbookURL: string) {
  const application = workbook.getApplication();
  application.calculate(ExcelScript.CalculationType.fullRebuild);
}

getCalculationEngineVersion()

返回用于上次完整重新计算的 Excel 计算引擎版本。

getCalculationEngineVersion(): number;

返回

number

getCalculationMode()

返回工作簿中使用的计算模式,由 中的 ExcelScript.CalculationMode常量定义。 可能的值为:Automatic,其中 Excel 控制重新计算;,AutomaticExceptTables其中 Excel 控制重新计算,但忽略表中的更改;Manual其中,计算在用户请求时完成。

getCalculationMode(): CalculationMode;

返回

getCalculationState()

返回应用程序的计算状态。 有关详细信息,请参阅 ExcelScript.CalculationState

getCalculationState(): CalculationState;

返回

示例

/**
 * 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;
  }
}

getCultureInfo()

提供基于当前系统区域性设置的信息。 这包括区域性名称、数字格式和其他区域性相关设置。

getCultureInfo(): CultureInfo;

返回

getDecimalSeparator()

获取用作数值的小数分隔符的字符串。 这基于本地 Excel 设置。

getDecimalSeparator(): string;

返回

string

getIterativeCalculation()

返回迭代计算设置。 在 Windows 和 Mac 上的 Excel 中,设置将应用于 Excel 应用程序。 在Excel web 版和其他平台中,这些设置将应用于活动工作簿。

getIterativeCalculation(): IterativeCalculation;

返回

getThousandsSeparator()

获取用于分隔数值的小数点左侧数字组的字符串。 这基于本地 Excel 设置。

getThousandsSeparator(): string;

返回

string

getUseSystemSeparators()

指定是否启用 Excel 的系统分隔符。 系统分隔符包括小数分隔符和千位分隔符。

getUseSystemSeparators(): boolean;

返回

boolean

setCalculationMode(calculationMode)

返回工作簿中使用的计算模式,由 中的 ExcelScript.CalculationMode常量定义。 可能的值为:Automatic,其中 Excel 控制重新计算;,AutomaticExceptTables其中 Excel 控制重新计算,但忽略表中的更改;Manual其中,计算在用户请求时完成。

setCalculationMode(calculationMode: CalculationMode): void;

参数

calculationMode
ExcelScript.CalculationMode

返回

void