Export (0) Print
Expand All

Ewa.EwaControl.add_workbookChanged(function)

apps for Office and SharePoint

Last modified: October 03, 2012

Applies to: apps for SharePoint | Excel Services | SharePoint Server 2013

In this article
Return Value
Remarks
Example

Subscribes an event handler to the workbookChanged event.

Ewa.EwaControl.add_workbookChanged(function);

function

The event handler to subscribe to the event.

The EwaControl.add_workbookChanged method subscribes an event handler to the workbookChanged event. The workbookChanged event is raised when the workbook is changed, including when the workbook is reloaded.

When the specified event handler for the workbookChanged event is invoked, it is invoked with a single argument of type Ewa.WorkbookEventArgs. The Ewa.WorkbookEventArgs object contains information about the workbook associated with the gridSynchronized event.

The following code example shows how to subscribe an event handler to the workbookChanged event that uses the Ewa.WorkbookEventArgs to display the path of the associated workbook in an alert message. The code example assumes that you are working with an Excel Web Access Web Part on SharePoint Server 2013.


<script type="text/javascript">
var ewa = null;

// Add event handler for onload event.
if (window.attachEvent) 
{ 
    window.attachEvent("onload", ewaOnPageLoad);    
} 
else 
{ 
    window.addEventListener("DOMContentLoaded", ewaOnPageLoad, false); 
}
// Add event handler for applicationReady event.
function ewaOnPageLoad()
{
    if (typeof (Ewa) != "undefined")
    {
        Ewa.EwaControl.add_applicationReady(ewaApplicationReady);
    }
    else
    {
        alert("Error - the EWA JS is not loaded.");
    }
}

function ewaApplicationReady()
{
    ewa = Ewa.EwaControl.getInstances().getItem(0);

    // Add event handler for workbookChanged event.
    ewa.add_workbookChanged(wkbookChanged);

}

function wkbookChanged(args)
{
    alert("The Workbook has changed.");
}
</script>

Show:
© 2014 Microsoft