Excel Desktop – Office.context.document.settings.get() 没有工作

huangapple go评论51阅读模式
英文:

Excel Desktop - Office.context.document.settings.get() didn't working

问题

当重新打开Excel文件时,它没有保留已保存的设置。
我能够使用Office.context.document.settings.set('key', value)。但是,当我尝试使用Office.context.document.settings.get()来获取设置时,它不起作用。

我希望状态应该被保存,下次打开文档时,我们应该检索已保存的值。

我正在使用Excel 2016标准版本
构建版本 - (16.0.4266.1001) 64位

英文:

When the excel file is reopened then it did not persist the saved settings.
I am able to do Office.context.document.settings.set('key', value). But when I try to get settings using Office.context.document.settings.get() it didn't working.

I want the state should be saved and the next time when we open the document we should retrieve the saved values

I am using Excel 2016 standard version
Build Version - (16.0.4266.1001) 64 bit

答案1

得分: 1

你需要调用 Office.Settings 接口的 saveAsync 方法,以将文档中设置属性包的内存副本持久化。

在加载外接程序时,之前由外接程序保存的任何设置都会被加载,因此在会话的生命周期内,您可以使用 setget 方法来处理设置属性包的内存副本。当您希望将设置持久保存,以便它们在下次使用外接程序时可用时,请使用 saveAsync 方法。

英文:

You need to call the saveAsync method of the Office.Settings interface to persist the in-memory copy of the settings property bag in the document.

Any settings previously saved by an add-in are loaded when it is initialized, so during the lifetime of the session you can just use the set and get methods to work with the in-memory copy of the settings property bag. When you want to persist the settings so that they are available the next time the add-in is used, use the saveAsync method.

huangapple
  • 本文由 发表于 2023年2月23日 22:05:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/75545874.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定