SoftTimur
SoftTimur

Reputation: 5490

Store information of workbook and add-in

There is an Excel add-in that allow users to make comments (not the traditional comments provided by Excel) for spreadsheet cells. The add-in memorizes all the cells that have comments in a workbook.

I am wondering where these information are actually stored. Are they stored in some hidden part of the workbook? Are they stored in the server of the add-in, then how are workbooks identified?

Upvotes: 2

Views: 137

Answers (2)

Michael Zlatkovsky
Michael Zlatkovsky

Reputation: 8670

If you're referring to an add-in that somehow "remembers" a particular Range across document open/close sessions (e.g., how the Bing Maps add-in does it), it's using Bindings beneath the covers. Bindings -- which are conceptually a lot like the user-facing Named Ranges, but are invisible and are per add-in (so no name collision risk) -- are stored in the document, just like named ranges.

As Kim points out, this is often combined with Settings to create an add-in that both binds to some ranges (with a GUID-like name, for example), and stores some metadata keyed off of the binding name.

On a side note, if you want to reference ranges only for a specific duration of time while the add-in is running but you don't need these to persist in the document, you can instead use object-tracking. It is described in great detail in the book "Building Office Add-ins using Office.js", (disclaimer: I am author of said book), in a chapter called "Using objects outside the 'linear' Excel.run or Word.run flow (e.g., in a button-click callback,in a setInterval, etc.)".

Upvotes: 2

Kim Brandl
Kim Brandl

Reputation: 13480

Using the Office.js API, you can use the Settings object (Office.context.document.settings) to store name/value pairs in the host document. For details about how this works, see the documentation here: https://dev.office.com/reference/add-ins/shared/settings.

As the documentation indicates, the settings that you create/save using the Settings object are saved per add-in and per document, which matches the scenario that you've described. Regarding where settings data actually gets stored, check out the answer on this other Stack Overflow post -- which describes how/where settings data is persisted for a host document. (Note: I haven't personally verified that answer, so I'd suggest that you do some testing to verify/confirm its accuracy for your scenario.)

Upvotes: 1

Related Questions