Unable to edit cells after a setSelectedDataAsync in Excel
Asked Answered
S

1

0

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?

Shaper answered 11/3, 2017 at 0:1 Comment(1)
I realize you are asking a broader behavior question, but it is helpful to provide example code, specifically a minimal, complete, verifiable example (stackoverflow.com/help/mcve)Vlaminck
S
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.

Stortz answered 11/3, 2017 at 21:2 Comment(1)
I found the cause of the while trying to build an example. As part of the add-in I have an Iframe embedded in the task pane, the Iframe was loading every time I invoked the command from the ribbon and It was taking the focus from Excel. I moved the function to a separate function file and now it is working as expected. Regarding setSelectedDataAsync working faster than .values set, I meant for just one write operation of a big matrix, I'm currently not batching instructions. Thank you very much for your time, and sorry for the confusion regarding the original issue. Regards!Epicenter

© 2022 - 2024 — McMap. All rights reserved.