Sebb77
Sebb77

Reputation: 2481

Access Excel CustomProperties from office-js

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.

Upvotes: 0

Views: 868

Answers (1)

Marcin Szałek
Marcin Szałek

Reputation: 5069

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

Upvotes: 1

Related Questions