OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
641 stars 92 forks source link

A custom function does not recalculate in Excel Online if the "at" (@) symbol has been used with the IF function #4398

Open s-ratashnyuk opened 3 weeks ago

s-ratashnyuk commented 3 weeks ago

Provide required information needed to triage your issue

Your Environment

Expected behavior

All functions recalculate

Current behavior

In Velixo sometimes we have to recalculate programmatically the sheet to make all values actual. Custom function, for example =@IF($B27 = ""; "";SI.WRITEBACKBUDGET($C$5;$F$12;$F$13;FALSE;$H$12:$I$13;$B27;;$D$6:$E$7;;$I$4:$T$4;$I27:$T27)) does not recalculate when we call context.workbook.worksheets.getActiveWorksheet().calculate(true);. It means Excel even does not start to execute the function. If we remove the @ before IF, functions become recalculating.

Steps to reproduce

Link to live example(s)

  1. The test file: https://velixo-my.sharepoint.com/:x:/p/sratashnyuk/EVdyU3MDhthCqswqK1naHNgBi_RfOA6e-lguI3-085u27A?e=R7tVPy

Provide additional details

I figured out that for the bug reproduction, the sheet has to contain spill range functions and in the buggy formula we have to use range references that contain IF in their formulas.

Context

In large sheets with complicated tables, it's important to use "@" and also have the ability to recalculate a sheet before, for example, uploading data to an external database.

Useful logs

microsoft-github-policy-service[bot] commented 3 weeks ago

Thank you for letting us know about this issue. We will take a look shortly. Thanks.

MiaofeiWang commented 1 week ago

Hi @s-ratashnyuk , thanks for reporting this. I am able to reproduce the issue on Excel on web with the steps you provided (thanks for the details). We have created internal work item 8935445 to track it.

Just to double confirm, this issue doesn't exist on Excel for Windows or Excel for Mac, right? I tried on both (replacing the body of function incrementBywith Math.random() for Windows), and with or without @, custom function can recalculate correctly.

s-ratashnyuk commented 1 week ago

Hi @MiaofeiWang! Thank you so much for your answer! Yes, the bug is reproduced only in Excel online and does not exist on Desktop versions. Have a nice day!