StorageEvent在Windows的Excel中不起作用 [英] StorageEvent does not work in Excel for Windows

查看:104
本文介绍了StorageEvent在Windows的Excel中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如某些现有线程所建议的(例如,一个三个),当前

As some existing threads suggest (eg, one, two, three), current Dialog Box does not provide an API to send regularly messages from the host page (eg, task pane) to the Dialog box.

所以我必须寻找一种解决方法:我们在localStorage中保留一个变量message,然后使<对话框>定期检查 (如果message的值发生变化).就像通过localStorage手动实现事件监听器一样.

So I have to look for a workaround: we reserve a variable message in localStorage, then we make the Dialog box check regularly if the value of message changes. It is like manually implementing an event listener by localStorage.

有人知道如何以一种确定且有效的方式来实现它(给定JavaScript不是多线程语言)?我不希望这个侦听器成本高昂,应该设置什么合适的时间间隔?

Does anyone know how to implement that in a sure and efficient way (given JavaScript isn't a multi-threaded language)? I don't want this listener to be costly, and what would be the appropriate interval to set?

我尝试了@PatrickEvans建议的StorageEvent.对于加载项和对话框站点,我们都需要通过存储中的变量messageFromHostToSitemessageFromSiteToHost实现sendMessage...receiveMessage....

I tried the StorageEvent that @PatrickEvans suggested. For both the add-in and the dialog site, we need to implement a sendMessage... and a receiveMessage... by the variables messageFromHostToSite and messageFromSiteToHost in storage.

它在Chrome的Excel Online和IE 11的Excel Online中都有效.我们可以将项目设置为localStorage并将其取回,更改localStorage似乎不会触发任何操作.

It worked in Excel Online in Chrome, and in Excel Online in IE 11. However, it did NOT work in Excel 2016 for Windows 7 or 10; we can set items to localStorage and get them back, changing localStorage seems to not fire anything.

因此,有人可以确认Windows 7或10的Excel 2016中确实不支持StorageEvent吗?在那种情况下,我仍在寻找其他解决方法...

So could anyone confirm that StorageEvent is indeed not supported in Excel 2016 for Windows 7 or 10? In that case, I am still looking for other workarounds...

我终于做了一个简化的例子:这是 xml文件,会调用加载项

I finally made a simplified example: here is the xml file, which calls the add-in and the site. It works well in Excel Online, but does NOT fire events in Excel for Windows.

推荐答案

我在应用之间进行通信时遇到类似的问题.在我的测试中,Excel Online storageEvent之所以有效,是因为通信是在同一实例"的浏览器选项卡之间进行的.使用Windows版Excel,2个加载项位于单独的浏览器实例"中.不传达storageEvents.更糟糕的是Office for Mac(WebKit);它不传递storageEvents,也无法从其他应用程序读取存储更改,除非重新启动它们-我相信这是因为存储值是为实例缓存的(未写入磁盘并且对其他实例/应用程序不可见)

I had similar issues communicating between apps. In my testing, Excel Online storageEvent works because the communication is between browser tabs of the same "instance". With Excel for Windows, 2 add-ins are in separate browser "instances"; which don't communicate storageEvents. Worse yet was Office for Mac (WebKit); which did not communicate storageEvents and also could not read storage changes from the other app unless they were restarted -- I believe this is because the storage values were cached for the instance (not written to disk and not visible to the other instance/app).

因此,我相信Excel Online可以使用StorageEvents,Excel for Windows将需要轮询(例如,每秒检查一次),而Excel for Mac可能需要基于服务器的解决方案,例如WebSockets.

So, I believe Excel Online could use StorageEvents, Excel for Windows would require polling (e.g. check every second), and Excel for Mac may require a server-based solution, such as WebSockets.

这篇关于StorageEvent在Windows的Excel中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆