Excel.Application class
Represents the Excel application that manages the workbook.
- Extends
Remarks
Properties
calculation |
Returns the calculation mode used in the workbook, as defined by the constants in |
context | The request context associated with the object. This connects the add-in's process to the Office host application's process. |
Methods
calculate(calculation |
Recalculate all currently opened workbooks in Excel. |
calculate(calculation |
Recalculate all currently opened workbooks in Excel. |
load(options) | Queues up a command to load the specified properties of the object. You must call |
load(property |
Queues up a command to load the specified properties of the object. You must call |
load(property |
Queues up a command to load the specified properties of the object. You must call |
set(properties, options) | Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. |
set(properties) | Sets multiple properties on the object at the same time, based on an existing loaded object. |
suspend |
Suspends calculation until the next |
toJSON() | Overrides the JavaScript |
Property Details
calculationMode
Returns the calculation mode used in the workbook, as defined by the constants in Excel.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.
calculationMode: Excel.CalculationMode | "Automatic" | "AutomaticExceptTables" | "Manual";
Property Value
Excel.CalculationMode | "Automatic" | "AutomaticExceptTables" | "Manual"
Remarks
context
The request context associated with the object. This connects the add-in's process to the Office host application's process.
context: RequestContext;
Property Value
Method Details
calculate(calculationType)
Recalculate all currently opened workbooks in Excel.
calculate(calculationType: Excel.CalculationType): void;
Parameters
- calculationType
- Excel.CalculationType
Specifies the calculation type to use. See Excel.CalculationType
for details.
Returns
void
Remarks
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/90-scenarios/performance-optimization.yaml
await Excel.run(async (context) => {
context.application.calculate(Excel.CalculationType.full);
});
calculate(calculationTypeString)
Recalculate all currently opened workbooks in Excel.
calculate(calculationTypeString: "Recalculate" | "Full" | "FullRebuild"): void;
Parameters
- calculationTypeString
-
"Recalculate" | "Full" | "FullRebuild"
Specifies the calculation type to use. See Excel.CalculationType
for details.
Returns
void
Remarks
Examples
await Excel.run(async (context) => {
context.workbook.application.calculate('Full');
await context.sync();
});
load(options)
Queues up a command to load the specified properties of the object. You must call context.sync()
before reading the properties.
load(options?: Excel.Interfaces.ApplicationLoadOptions): Excel.Application;
Parameters
Provides options for which properties of the object to load.
Returns
load(propertyNames)
Queues up a command to load the specified properties of the object. You must call context.sync()
before reading the properties.
load(propertyNames?: string | string[]): Excel.Application;
Parameters
- propertyNames
-
string | string[]
A comma-delimited string or an array of strings that specify the properties to load.
Returns
Examples
await Excel.run(async (context) => {
const application = context.workbook.application;
application.load('calculationMode');
await context.sync();
console.log(application.calculationMode);
});
load(propertyNamesAndPaths)
Queues up a command to load the specified properties of the object. You must call context.sync()
before reading the properties.
load(propertyNamesAndPaths?: {
select?: string;
expand?: string;
}): Excel.Application;
Parameters
- propertyNamesAndPaths
-
{ select?: string; expand?: string; }
propertyNamesAndPaths.select
is a comma-delimited string that specifies the properties to load, and propertyNamesAndPaths.expand
is a comma-delimited string that specifies the navigation properties to load.
Returns
set(properties, options)
Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type.
set(properties: Interfaces.ApplicationUpdateData, options?: OfficeExtension.UpdateOptions): void;
Parameters
- properties
- Excel.Interfaces.ApplicationUpdateData
A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called.
- options
- OfficeExtension.UpdateOptions
Provides an option to suppress errors if the properties object tries to set any read-only properties.
Returns
void
set(properties)
Sets multiple properties on the object at the same time, based on an existing loaded object.
set(properties: Excel.Application): void;
Parameters
- properties
- Excel.Application
Returns
void
suspendApiCalculationUntilNextSync()
Suspends calculation until the next context.sync()
is called. Once set, it is the developer's responsibility to re-calc the workbook, to ensure that any dependencies are propagated.
suspendApiCalculationUntilNextSync(): void;
Returns
void
Remarks
toJSON()
Overrides the JavaScript toJSON()
method in order to provide more useful output when an API object is passed to JSON.stringify()
. (JSON.stringify
, in turn, calls the toJSON
method of the object that is passed to it.) Whereas the original Excel.Application
object is an API object, the toJSON
method returns a plain JavaScript object (typed as Excel.Interfaces.ApplicationData
) that contains shallow copies of any loaded child properties from the original object.
toJSON(): Excel.Interfaces.ApplicationData;
Returns
Office Add-ins