0

I am executing formulas with the help of the Office JS API.

For this, I am following the below steps to execute the formula. I am first getting the Excel range and executing the formula in that range.

https://learn.microsoft.com/en-us/office/dev/add-ins/excel/excel-add-ins-ranges-set-get-values

Is there any way to get formula results by executingng this formula without using the range?

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
Poojan3037
  • 310
  • 1
  • 9

1 Answers1

0

Your add-in may react to changing the data in a worksheet. To detect these changes, you can register an event handler for the onChanged event of a worksheet. Event handlers for the onChanged event receive a WorksheetChangedEventArgs object when the event fires.

The WorksheetChangedEventArgs object provides information about the changes and the source. Since onChanged fires when either the format or value of the data changes, it can be useful to have your add-in check if the values have actually changed. The details property encapsulates this information as a ChangedEventDetail. The following code sample shows how to display the before and after values and types of a cell that has been changed.

// This function would be used as an event handler for the Worksheet.onChanged event.
function onWorksheetChanged(eventArgs) {
    Excel.run(function (context) {
        let details = eventArgs.details;
        let address = eventArgs.address;

        // Print the before and after types and values to the console.
        console.log(`Change at ${address}: was ${details.valueBefore}(${details.valueTypeBefore}),`
            + ` now is ${details.valueAfter}(${details.valueTypeAfter})`);
        return context.sync();
    });
}

See Work with worksheets using the Excel JavaScript API for more information.

Note, you can post or vote for an existing feature request on Tech Community where they are considered when the Office dev team goes through the planning process.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45