Getactivecell,in doc(cell) which is opened with onlyoffice documentserver?

how to get activecell in doc(cell) which is opened with onlyoffice documentserver?
and how to change the content in cell which is opened with onlyoffice documentserver? api?

Hello,
Here is an example macro:
https://api.onlyoffice.com/plugin/macrosamples/writedatatoworksheetcell

1 Like

Thank you for your reply!

The problem is that it may be inconvenient to use macros to solve problems. For example, the cells where I need to modify values change, so I shouldn’t edit the macro code every time.

My expectation is to modify the value of the cell through JS code outside the iframe. Is there a way? Or front-end API interface

Or I want to write code through my application to affect the document values within the integrated framework.

You can write a plugin that would use these methods to modify cell values.

write a plugin is not the best way for me。Because the plug can’t be part of my complete code.

Is there a way like docbuilder API to change the files opened in DS? For example, getactivecell(); Setactive(), etc

You cannot change the document that is currently opened in the editor with the builder. The only way to use builder methods in an edited document is plugin/macro.

1 Like

我可以通过js读写cell吗?不是通过宏,就是通过html中的javascript代码?

I want to run the macro using JavaScript in index.html (while passing in the necessary parameters for macro execution, such as cell position); Is there any other way to read and write cells using JavaScript?

I am trying to install the externalister plugin from the GitHub - ONLYOFFICE/sdkjs-plugins: The add-ons for ONLYOFFICE Document Server and ONLYOFFICE Desktop Editors. Download. Is this plugin suitable for all OO versions? I’m not sure if the installation was successful, but I used test.HTML and it didn’t work. Which version of installation do you recommend and which method is more secure? Which test. HTML did not load the document? Can you provide an example of loading the document? I would like to use this plugin to read and write cell values or scroll through the screen. Thank you

(function(window, undefined){

window.Asc.plugin.init = function()
{
	// none
		console.log("button-init ","init");
        			
        window.addEventListener('message', function(event) {
            if (event.source === window.parent) { // 确保消息来自于正确的源
                if (typeof event.data === 'string') {
                    let data = JSON.parse(event.data);
                    switch (data.type) {
                        case 'insertText':
                            // 处理自定义消息
                            console.log("Received custom message:", data);
                            break;
                        default:
                            // 处理其他类型的消息
                            console.log("Received custom message: no insertText--data", data);
                            console.log("Received custom message: no insertText--data.type",data.type);
                            console.log("Received custom message: no insertText--data.text",data.text);
                            break;
                    }
                }
            }
        });			
		
		
};

but get message from console:

Received custom message: no insertText–data.type onExternalMouseUp
code.js:38
Received custom message: no insertText–data.text undefined

why?

Hello @xcar
The externallistener plugin is outdated. However, Document Server is capable of listening for the data from external sources with Developer Edition license, for such cases the connector class of Automation API must be used:
https://api.onlyoffice.com/editors/connector

If you are interested in obtaining Developer Edition license of Document Server, please contact our Sales Department via sales@onlyoffice.com to get more information.