sdkjs-plugins icon indicating copy to clipboard operation
sdkjs-plugins copied to clipboard

Unable to get cell value outside of command scope

Open vese opened this issue 3 years ago • 4 comments

Hi! I need to parse value from cell and display it in plugin's window. How can I do this?

document.getElementById("parse").onclick = function () {
  callCommand(function () {
    const value = Api.ActiveSheet.ActiveCell.Value;
    // need to get value outside of command scope
  }, false);
};

If use onCommandCallback I also can't get the value

window.Asc.plugin.onCommandCallback = function (returnValue) {
//returnValue is null

}

If use executeMethod I get returnValue in onMethodReturn for some methods, e. g. GetFontList

  window.Asc.plugin.executeMethod('GetFontList');

But I can't get cell value. ('GetActiveSheet', 'GetActiveCell') Is there any method to get cell value?

vese avatar May 05 '21 19:05 vese

@askonev Please take a look

ShockwaveNN avatar May 06 '21 08:05 ShockwaveNN

It is possible to get selected value if specify "initOnSelectionChanged": true and "initDataType": "text" or "initDataType": "html" in config.json. But it seems like workaround instead of an actual way to get value. Also it is impossible to get selected cells adresses this way because init data has no this information

vese avatar May 12 '21 14:05 vese

Hello @vese. This is exactly how the implementation of data access from the editor to the plugin was conceived. I think you have already familiarized yourself with the implementation of the Thesaurus plugin in which this configuration is used.

But direct access to the cell address is not implemented, but you can add it to the cell using Api methods and then take the data into the plugin.

askonev avatar Jun 02 '21 17:06 askonev

Hello @askonev. Is it possible to add parameters to callbacks from callCommand https://github.com/ONLYOFFICE/sdkjs/pull/1964 ?

vese avatar Jun 03 '21 16:06 vese