attachEvent

attachEvent(eventName, callback)

Subscribes to the specified event and calls the callback function when the event fires.

Parameters:

Name Type Description
eventName string

The event name.

callback function

Function to be called when the event fires.

Returns:

This method doesn't return any data.

Example

Copy code
builder.CreateFile("xlsx");
var oWorksheet = Api.GetActiveSheet();
var oRange = oWorksheet.GetRange("A1");
oRange.SetValue("1");
Api.attachEvent("onWorksheetChange", function(oRange){
    console.log("onWorksheetChange");
    console.log(oRange.GetAddress());
});
builder.SaveFile("xlsx", "attachEvent.xlsx");
builder.CloseFile();

Resulting document