Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lumine2008/b374adeec2697cd43d3f65b7459f34ef to your computer and use it in GitHub Desktop.
Save lumine2008/b374adeec2697cd43d3f65b7459f34ef to your computer and use it in GitHub Desktop.
Issue with document settings
name: 'Origin SAP: Issue with document settings'
description: Issue with document settings
host: EXCEL
api_set: {}
script:
content: |
$("#save").click(() => tryCatch(save));
$("#read").click(() => tryCatch(read));
async function save() {
await Excel.run(async (context) => {
Office.context.document.settings.set("setting1", "value1");
Office.context.document.settings.saveAsync();
});
}
async function read() {
await Excel.run(async (context) => {
Office.context.document.settings.refreshAsync((result: Office.AsyncResult<Office.Settings>) => {
const value1 = result.value.get("setting1");
console.log("current value: " + value1);
});
});
}
/** Default helper for invoking an action and handling errors. */
async function tryCatch(callback) {
try {
await callback();
} catch (error) {
// Note: In a production add-in, you'd want to notify the user through your add-in's UI.
console.error(error);
}
}
language: typescript
template:
content: "<section class=\"samples ms-font-m\">\n\t<p class=\"ms-font-m\">Reproduction of the issue:</p>\n\t<ol>\n\t\t<li>Run the snippet in Excel Online</li>\n\t\t<li>Click the \"Save settings\" button</li>\n\t\t<li>Click the \"Read settings\" button and check that the console shows \"current value: value1\"</li>\n\t\t<li>Open the same workbook in Windows Excel / MAC Excel</li>\n\t\t<li>Run the snippet</li>\n\t\t<li><b>ONLY</b> click the \"Read settings\" button</li>\n\t\t<li>Expected behavior: you should see \"current value: value1\" on the console</li>\n\n\t</ol>\n\t<button id=\"save\" class=\"ms-Button\">\n <span class=\"ms-Button-label\">Save settings</span>\n </button>\n\t<button id=\"read\" class=\"ms-Button\">\n\t <span class=\"ms-Button-label\">Read settings</span>\n\t </button>\n</section>"
language: html
style:
content: |-
section.samples {
margin-top: 20px;
}
section.samples .ms-Button, section.setup .ms-Button {
display: block;
margin-bottom: 5px;
margin-left: 20px;
min-width: 80px;
}
language: css
libraries: |
https://appsforoffice.microsoft.com/lib/1/hosted/office.js
@types/office-js
[email protected]/dist/css/fabric.min.css
[email protected]/dist/css/fabric.components.min.css
[email protected]/client/core.min.js
@types/core-js
[email protected]
@types/[email protected]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment