I'm trying to update my Excel add-in to use the workbook SettingCollection
instead of the Office.context.document.settings
object. The documentation seems to suggest they are functionally equivalent, but with document.settings
I can call saveAsync()
and see my data persisted (in the PropertyBag in a webextensions.xml).
With ctx.workbook.settings.add('key', 'value')
, I can get the settings and get them in the current session, but they don't get added to the webextensions.xml
and aren't available on the next open of the add-in.
Is there a version of saveAsync
for workbook settings that I'm missing? I assumed context.sync
would take care of it, but I haven't had any luck.
Edit: I figured out what was causing my initial issue, but the problem is still there. When I close the browser tab with Excel Online and re-open it with my add-in, the settings are not persisting. Nothing is getting added to webextensions.xml
.
Here is an example Excel.run()
window.Excel.run(async ctx => {
ctx.workbook.settings.add('hello', 'world');
await ctx.sync();
let setting = ctx.workbook.settings.getItemOrNullObject('hello');
setting.load('value');
await ctx.sync();
console.log(setting.value);
});
The setting 'hello' sets and exists the next if I relaunch my add-in, but not if I close the file and open my add-in.