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

Unique Identifier for a defined name (name range) [Excel] [feature Request] #1508

Closed achang0406 closed 5 years ago

achang0406 commented 5 years ago

There is currently no reliable way to uniquely identify a defined name.

We are currently juggling with a few workarounds.

workarounds


#1 use worksheet + cell range to uniquely identify a defined name for example:

{
  worksheet1!A1:C4: definedName1,
  worksheet1!D23:F8: definedName2,
  ...
}

risks There can be multiple defined names in the exact same worksheet + cell range.


#2 use the name of a defined name for its ID

risks the name of defined names can be renamed which makes it not unique. Client side will have to somehow detect the change and edit all corresponding defined name which is an open issue, https://github.com/OfficeDev/office-js-docs/issues/1507.


Proposed Solution

Excel generates a unique ID when a defined name is created. The ID will be independent from the path of the cell range and the name of the defined name. Then this ID would be accessible from an API or the defined name object.

weshi commented 5 years ago

Does binding object help in this case? Binding has unique ID exposed in the API (https://github.com/OfficeDev/office-js-docs/blob/ExcelJs_OpenSpec/reference/excel/binding.md).

achang0406 commented 5 years ago

We are having trouble seeing how the binding object is able to provide a unique immutable (unchangeable) ID for a defined name object that is independent from the cell range and the name of the defined name.

The binding object seem to provide a way to tie event listeners and attributes to a group of cells or individual cells but does not actually add attributes to the defined name object.

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.