有没有办法在Office 2013和VBA的自定义或任务窗格应用程序内运行的JavaScript之间直接共享数据?
目前,我正在使用Office API绑定来处理此问题,以观察,读取和写入工作表单元格的数据。例如:
Office.context.document.bindings.addFromNamedItemAsync("Example!A1:A1", Office.BindingType.Matrix, { id: "readFromCell" }, function (asyncResult) {
Office.select("bindings#readFromCell").getDataAsync({ coercionType: "matrix" }, function (asyncResult) {
if (asyncResult.status === Office.AsyncResultStatus.Succeeded) {
processData(asyncResult.value);
}
});
});
然而,这种方法太慢而且凌乱。我正在寻找更接近这个的东西:
VBA:
CommonStorage.setValue("example", "hello")
JavaScript的:
var example = CommonStorage.getValue("example"); // Returns "hello"