Unable to edit cells after a setSelectedDataAsync in Excel

杀马特。学长 韩版系。学妹 提交于 2019-12-12 04:19:34

问题


I'm developing an add-in for Excel using the Office Add-ins platform. In this add-in I'm writing data to a range using the setSelectedDataAsync** function. It works fine, but after the data is written, I'm not able to delete or edit the cells (although I can select new ranges) unless I click anywhere outside the worksheet or double click a cell. I think it is an issue with Excel not regaining focus correctly (the filename in the top of the app remains grayed out).

Some users seem to think that Excel becomes unresponsive, which is a problem.

Is this a known issue? Is there a work around for this?

** I have noticed that setSelectedDataAsync is way, way quicker than setting range.values to a matrix and then ctx.sync(). Am I losing some important functionality by not using the latter method?


回答1:


This is not a known issue (unable to interact with worksheet after setting the data). We can look into that.

Surprised to hear that setSelectedDataAsync works faster than the range.values set. The batched syntax allows you to combine not just one instruction, but many related instructions such as setting number format, font, background, etc. and you can do a single sync() to send all instructions in one batch. So, it is more efficient when you combine related instructions together.

There is no restriction of which API to use as such; however the Excel1.1 version was introduced with Office 2016 and then there have been many releases since then incrementally adding new features along the way.

setSelectedDataAsync() API was designed to work across hosts such as Excel, Word, etc. and hence doesn't go deeper in-terms of setting number format, formats, etc.



来源:https://stackoverflow.com/questions/42729712/unable-to-edit-cells-after-a-setselecteddataasync-in-excel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!