Closed GeorgeHung closed 5 years ago
@GeorgeHung can you share with us your "Refresh then Read Setting" code also ? It would be great that you could share with us your gist link .
Please find the code below. It is also in the YAML which I included in the issue request.
function readWR() {
Office.context.document.settings.refreshAsync(function(asyncResult) {
console.log("Settings refresh with status: " + asyncResult.status);
console.log("testSetting is " + Office.context.document.settings.get("testSetting"));
});
}
@GeorgeHung is it possible for you to try API https://docs.microsoft.com/en-us/javascript/api/excel/excel.setting?view=office-js, this is new API and should work as you expected.
The new api seems to allow me to read the values from the settings. However, I am having issue using the new api to write to the settings. You can close this bug. I will file another one for the other issue.
Shouldn’t this get fixed (even if there’s another API that can be used)? I'm encountering what seems to be the same problem.
I tried the Script Lab example given above. It works as expected in Excel for Mac (first screenshot), but in Office Online, the setting seems to get lost upon doing “refreshASync” (second screenshot).
The console on each screenshot shows the output of using “Read Setting”, “Save Setting”, “Read Setting”, “Refre(s)h then Read Setting”, “Read Setting”.
Versions used: Excel 16.28 (19081202) and Chrome 78.0.3904.108 on macOS 10.13.6
Excel for Mac:
Office Online:
Running Office.context.document.settings.refreshAsync causes data in setting to be removed.
Expected Behavior
RefreshAsync should get data saved with Office.context.document.settings.saveAsync
Current Behavior
Running Office.context.document.settings.refreshAsync caused data in setting to be removed.
Steps to Reproduce, or Live Example
Context
We use settings to save data in the documents.
Your Environment