0
votes

We are implementing a version of a vsto for excel 2013 add-in for excel online. Currently the application makes use of document properties to store data in the file. Something like:

Excel.Worksheet sheet = Application.ActiveSheet as Excel.Worksheet;
sheet.CustomProperties.Add(key, value);

and this to read the value:

Excel.CustomProperties props = sheet.CustomProperties;
foreach (Excel.CustomProperty prop in props)
{
    if (prop != null)
    {
        string pn = prop.Name;
        if (propName.Equals(pn))
            return prop;
    }
}

In Excel online there is this code in order to store the same information:

Office.context.document.settings.set(key, value);
Office.context.document.settings.save();

and this to read:

Office.context.document.settings.get(key);

However it seems that these two data are not the same.

Is there a way to read such information using office JS API for Excel online? We already know that such functionality is available for Word online, but it doesn't seem to be available for excel; see https://dev.office.com/reference/add-ins/word/customproperty

How can we make sure that a file containing metadata created with normal excel desktop (2013 and 2016) can be used in office online as expected, and vice versa?

Note: For the time being it is not possible to create just one addin for desktop and online.

1
Since this question is about office-js and it is in no way the same as VSTO, I've removed the VSTO tag. People who read and answer questions about VSTO have no interest in this question. - Cindy Meister
Please give an example to demonstrate how the two are not the same. - Cindy Meister
I'm asking if there is a way to read data to one system to another. So if we save data using vsto we would like to read and set from office-js. If this is not possible we save data using office-js and read using vsto. We want a way to save and retrieve worksheet information that is compatible in both systems. So I think the vsto tag was appropriate. - Sebb77
The two above examples, vsto and office-js are not compatible simply because if I use the same key name one does not retrieve the data saved with the other technology. E.g. Create a new VSTO addon which saves some string in the CustomProperties of the current sheet (example above shows how to do it). Then Create an office-js addin and try to read the same value. Even if you do the other way round (office-js -> vsto) data is not retrieved. - Sebb77

1 Answers

1
votes

I think this post solves the issue.
Basically, you need to use Workbook's CustomDocumentProperties instead of worksheet's ones.