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
670 stars 96 forks source link

[Excel API] Programatically disable excel edit mode or ability to exit edit mode #3323

Open miranda18 opened 1 year ago

miranda18 commented 1 year ago

Hello!

This feature request is related to the issue that other users seem to be facing as well. Please find the encountered error below:

"RichApi.Error: Excel is in cell-editing mode. Please exit the edit mode by pressing ENTER or TAB or selecting another cell, and then try again."

Related bugs:https://github.com/OfficeDev/office-js/issues/856https://github.com/OfficeDev/office-js/issues/792https://github.com/OfficeDev/office-js/issues/791

Our add-in scenario:

  1. A user presses a button to load data into the sheet
  2. Sheet creation begins
  3. Data populates into the sheet
  4. Sheet creation ends
  5. User is able to edit desired cells

Where the issue/error is being faced:

  1. A user presses a button to load data into the sheet
  2. During sheet creation, the user either:
    • Spam clicks in the sheet -> edit mode gets enabled
    • Clicks into the sheet and begins to type -> edit mode gets enabled
  3. Sheet creation immediately fails
  4. User receives error

*Note: Our sheet creation takes time as we are making multiple excel API calls.

Hoping for any of the following solutions:

  1. Temporarily disable edit mode in the sheet to reduce the chance of encountering the edit mode error, which would allow us to run our sheet creation tasks without accidental/intentional user interruption.
  2. Detect if user is in edit mode. If they are, programmatically exit edit mode for the user, so they do not encounter this error, or receive a prompt/message to exit edit mode in order to continue with the action they attempted.

Currently I have found that someone has opened a feature request similar to the above: https://techcommunity.microsoft.com/t5/microsoft-365-developer-platform/improving-excel-add-in-api-failures-when-in-celleditmode/idi-p/3201549

Any feedback would be greatly appreciated. Thank you in advance!

damacisaac commented 8 months ago

Facing the same issue. We also have sheet creation events that take time, and background tasks that run periodically, both of which fail if the user is in cell editing mode. As @miranda18 suggested, being able to detect cell editing mode so that we can notify the user of the issue could be helpful.

Also it seems like there are many API calls that could be enabled while cell-editing mode is active, particularly ones that are read-only.

@JinghuiMS is there any update on this?

HugoAlbertoNieto commented 6 months ago

I'm also having the same issue as @miranda18 and @damacisaac. @JinghuiMS is there any update or may be a suggested workaround for this?

shanshanzheng-dev commented 1 week ago

Hi @HugoAlbertoNieto could you please give us some repro steps or repro video? Thanks.

damacisaac commented 1 week ago

@shanshanzheng-dev there's a clear repro in the issue description. Can you use that? It's very easy to repro based on the examples given by myself and @miranda18.

shanshanzheng-dev commented 1 week ago

@damacisaac Thanks, we'll take a look and report back if we have a suggestion for you.