Search code examples
javascriptoffice-jsexcel-addins

Excel JavaScript API - How to change calculation mode


This is my code:

Excel.Application.set({calculationMode: "Manual"});

But the compiler throws

TS2339: Property 'set' does not exist on type 'typeof Application'.

What is the api to change calculation mode?


Solution

  • I think you just need to set the calculation mode in a context like in the following code.

    async function setCalculationMode() {
      await Excel.run(async (context) => {
        context.application.calculationMode = Excel.CalculationMode.manual;
        await context.sync();
      });
    }