OfficeDev / office-js-docs

[ARCHIVED] Microsoft Office Add-ins API Reference Documentation
https://docs.microsoft.com/javascript/api/overview/office
398 stars 247 forks source link

Event Listeners for when defined name is created or modified [Excel] [Feature Request] #1507

Closed achang0406 closed 5 years ago

achang0406 commented 5 years ago

Similar to issue https://github.com/OfficeDev/office-js-docs/issues/1503

Issue 1

There are no event listener when a new defined name is created inside excel.

workaround

Our current proposed workaround is similar to the conditional formatting workaround where we check Excel. NamedItemCollection.getCount every 5 seconds to check whether size is different. If it is different than this would mean that the user has created a new defined name (named range).

risk poor performance, heaving client logic

Proposed Solution 1 Implement an onAdd event listener for Excel.NamedItemCollection to notify any new defined name being created. This would prevent our client having to periodically check for new define names.

This event listener should have at least the below data in the arguments:

  1. the created defined name a. worksheet name b. cell range

Issue 2

There are currently also no way to detect when an existing defined name is being edited (in the case of renaming a defined name or modifying the cell range).

workaround

  1. Client has to create an update button for the user to detect any new defined names.
  2. Every 5 seconds call Excel.NamedItemCollection.items to get the whole list of defined names and compare with the previous list of defined names to see any has changed.

risk Poor performance, heavy client logic

proposed Solution 2 Implement an onChange event listener for Excel.NamedItemCollection to notify any new defined name being modified.

This event listener should have at least the below data in the arguments:

  1. the updated defined name a. updated worksheet name b. updated cell range c. the previous change (cell range, name of the defined name, etc)
weshi commented 5 years ago

Added to our internal backlog and will do planning accordingly.

Product Backlog Item 2626621: [Customer Ask] Adding onChanged event for NamedItem/NamedItemCollection

Thank you for the feedback.

kbrandl commented 5 years ago

@achang0406 if you haven't already done so, can you please log this as a feature request in UserVoice? We'll be archiving this repository (OfficeDev/office-js-docs) soon.