ExcelScript.Application interface
Represents the Excel application that manages the workbook.
Methods
calculate(calculation |
Recalculate all currently opened workbooks in Excel. |
get |
Returns the Excel calculation engine version used for the last full recalculation. |
get |
Returns the calculation mode used in the workbook, as defined by the constants in |
get |
Returns the calculation state of the application. See |
get |
Provides information based on current system culture settings. This includes the culture names, number formatting, and other culturally dependent settings. |
get |
Gets the string used as the decimal separator for numeric values. This is based on the local Excel settings. |
get |
Returns the iterative calculation settings. In Excel on Windows and Mac, the settings will apply to the Excel Application. In Excel on the web and other platforms, the settings will apply to the active workbook. |
get |
Gets the string used to separate groups of digits to the left of the decimal for numeric values. This is based on the local Excel settings. |
get |
Specifies if the system separators of Excel are enabled. System separators include the decimal separator and thousands separator. |
set |
Returns the calculation mode used in the workbook, as defined by the constants in |
Method Details
calculate(calculationType)
Recalculate all currently opened workbooks in Excel.
calculate(calculationType: CalculationType): void;
Parameters
- calculationType
- ExcelScript.CalculationType
Specifies the calculation type to use. See ExcelScript.CalculationType
for details.
Returns
void
Examples
/**
* 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()
Returns the Excel calculation engine version used for the last full recalculation.
getCalculationEngineVersion(): number;
Returns
number
getCalculationMode()
Returns the calculation mode used in the workbook, as defined by the constants in ExcelScript.CalculationMode
. Possible values are: Automatic
, where Excel controls recalculation; AutomaticExceptTables
, where Excel controls recalculation but ignores changes in tables; Manual
, where calculation is done when the user requests it.
getCalculationMode(): CalculationMode;
Returns
getCalculationState()
Returns the calculation state of the application. See ExcelScript.CalculationState
for details.
getCalculationState(): CalculationState;
Returns
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;
}
}
getCultureInfo()
Provides information based on current system culture settings. This includes the culture names, number formatting, and other culturally dependent settings.
getCultureInfo(): CultureInfo;
Returns
getDecimalSeparator()
Gets the string used as the decimal separator for numeric values. This is based on the local Excel settings.
getDecimalSeparator(): string;
Returns
string
getIterativeCalculation()
Returns the iterative calculation settings. In Excel on Windows and Mac, the settings will apply to the Excel Application. In Excel on the web and other platforms, the settings will apply to the active workbook.
getIterativeCalculation(): IterativeCalculation;
Returns
getThousandsSeparator()
Gets the string used to separate groups of digits to the left of the decimal for numeric values. This is based on the local Excel settings.
getThousandsSeparator(): string;
Returns
string
getUseSystemSeparators()
Specifies if the system separators of Excel are enabled. System separators include the decimal separator and thousands separator.
getUseSystemSeparators(): boolean;
Returns
boolean
setCalculationMode(calculationMode)
Returns the calculation mode used in the workbook, as defined by the constants in ExcelScript.CalculationMode
. Possible values are: Automatic
, where Excel controls recalculation; AutomaticExceptTables
, where Excel controls recalculation but ignores changes in tables; Manual
, where calculation is done when the user requests it.
setCalculationMode(calculationMode: CalculationMode): void;
Parameters
- calculationMode
- ExcelScript.CalculationMode
Returns
void
Office Scripts