Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to capture worksheet/cell change events? #130

Open
lapnd opened this issue Oct 9, 2020 · 7 comments
Open

How to capture worksheet/cell change events? #130

lapnd opened this issue Oct 9, 2020 · 7 comments
Labels
feature request Issues that request new features to be added to OnlyOffice

Comments

@lapnd
Copy link

lapnd commented Oct 9, 2020

Hi,
Thank for the great project.
As we know, Microsoft Excel and OfficeJs addins allow us to listen event when a worksheet and/or a cell changed.
Is there anyway to listen these change events with OnlyOffice via plugin/macro?
Thank you!

@lapnd lapnd changed the title How to watch the capture worksheet/cell change events? How to capture worksheet/cell change events? Oct 9, 2020
@ShockwaveNN
Copy link
Contributor

@flaminestone Please, take a look

@flaminestone
Copy link

Hello @lapd-viosoft.This feature is in development and has not been documented yet.
What you mean with worksheet change event? In spreadsheet editor, every cell change (or double click in any cell) will trigger this event, and I do not know any case for using this.

@lapnd
Copy link
Author

lapnd commented Oct 9, 2020

Hello @flaminestone
In Excel, with VBA macro, we can watch the change of each cell and do further processing. For example:

Private Sub Worksheet_Change(ByVal Target As Excel.Range) 
    If Target.Column = 1 Then 
        ThisRow = Target.Row 
        If Target.Value > 100 Then 
            Range("B" & ThisRow).Interior.ColorIndex = 3 
        Else 
            Range("B" & ThisRow).Interior.ColorIndex = xlColorIndexNone 
        End If 
    End If 
End Sub

Or with OfficeJs addins, we can do like this

// Register change event
Excel.run(function (context) {
    var worksheet = context.workbook.worksheets.getItem("Sample");
    worksheet.onChanged.add(handleChange);

    return context.sync()
        .then(function () {
            console.log("Event handler successfully registered for onChanged event in the worksheet.");
        });
}).catch(errorHandlerFunction);


function handleChange(event)
{
    return Excel.run(function(context){
        return context.sync()
            .then(function() {
                console.log("Change type of event: " + event.changeType);
                console.log("Address of event: " + event.address);
                console.log("Source of event: " + event.source);
   
            });
    }).catch(errorHandlerFunction);
}

In spreadsheet editor, every cell change (or double click in any cell) will trigger this event, and I do not know any case for using this.

Can you tell me how to capture this cell change event in plugin/macro or any background thread of editor?

I have scenario like:

  • A plugin as system plugin, run in background and listen the change of every cell.
  • When a cell is changed (ex: user input some value, or paste new value, or select new value from drop down list) , the plugin captures new content of the cell, check the new content against some rules....and give warning to user if the new value is invalid.

Thank you.

@flaminestone
Copy link

flaminestone commented Oct 9, 2020

Can you tell me how to capture this cell change event in plugin/macro or any background thread of editor?

It is not available now, this functional is in development.

This is example for using some available events

@lapnd
Copy link
Author

lapnd commented Oct 10, 2020

Hi @flaminestone
Thank you very much for your information!

@gamead
Copy link

gamead commented Jul 19, 2022

Is it available for now?

@l8556
Copy link
Member

l8556 commented Jul 19, 2022

Hi @gamead !
These methods are still in development.
Improvement request in our internal repository #58189

@ShockwaveNN ShockwaveNN added the feature request Issues that request new features to be added to OnlyOffice label Jul 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to OnlyOffice
Projects
None yet
Development

No branches or pull requests

5 participants