Closed ChiuJun closed 1 year ago
Hi @ChiuJun
You can access the data in the spreadsheet by using execute methods from the documentation, for example, can get the selected text via method: window.Asc.plugin.executeMethod("GetSelectedText", [args], callback)
Or, as you note, can get the selected text when plugin run through setting variations.initDataType in the plugin configuration file.
It is also possible to perform data actions with builder methods via window.Asc.plugin.callCommand.
Hi @ChiuJun
You can access the data in the spreadsheet by using execute methods from the documentation, for example, can get the selected text via method: window.Asc.plugin.executeMethod("GetSelectedText", [args], callback)
Or, as you note, can get the selected text when plugin run through setting variations.initDataType in the plugin configuration file.
It is also possible to perform data actions with builder methods via window.Asc.plugin.callCommand.
Thank you so much @l8556
I have checked the API you mentioned(executeMethod and callCommand) before creating this issue.They all have their own limitations and cannot do what Builder API can do.
For the executeMethod API:
executeMethod(name, params, callback) → { boolean }
Name | Type | Description |
---|---|---|
name | string | The name of the specific method that must be executed. |
The values allowed for its parameter name may different from Builder API, but I haven't tried the method names in the Builder API. e.g. Spreadsheet Api under the executeMethod Docs.
Name | Description |
---|---|
AddComment | Adds a comment to the workbook. |
ChangeComment | Changes the specified comment. |
RemoveComments | Removes the specified comments. |
For the callCommand API:
Documentation describes that it has its own context, it seems to be via JavaScript eval()
This method is executed in its own context isolated from other JavaScript data. If some parameters or other data need to be passed to this method, use Asc.scope object.
Hi @ChiuJun! There is currently no way to get data from the plugin context for security reasons. We provide an api plugin to manipulate document data at this time. The ONLYOFFICE team is working on a solution to this problem
Do you want to request a feature or report a bug? feature What is the current behavior? As described in the ONLYOFFICE Plugins API Docs We can pass data one-way through
Asc.scope
object to the plugin code inwindow.Asc.plugin.callCommand
method.And we can get the selected text when plugin run through setting variations.initDataType in the plugin configuration file.
But I can't find any other way to get the spreadsheet data in the API Docs,this question seems to be similar to #154 .And I think the https://github.com/ONLYOFFICE/sdkjs/pull/1964 mentioned in it is a good feature. So is there any other way to access the data in the spreadsheet ?
By the way, I used the unofficial way to directly call the API instead of overriding
window.Asc.plugin.callCommand
method, so that my plugin can get the spreadsheet data.Thanks !