Export (0) Print
Expand All

Ewa.RangeEditEventArgs Object

apps for Office and SharePoint

Last modified: October 04, 2012

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

An object that you can use to both to get references to other objects related to a given instance of the event, and to get and set data, such as values that are contained in the associated range.

Ewa.RangeEditEventArgs

Use the methods of the Ewa.RangeEditEventArgs object to get the values of the cells in the range, to get a reference to the range itself, or to get a reference to the workbook that contains the range. Additionally, you can use the Ewa.RangeChangeEventArgs.getEwaControl() method to get the Ewa.EwaControl Object object that represents the Excel Web Access Web Part.

The following code example subscribes an event handler to the commitCellEditing event. The code also shows how to use the Ewa.RangeEditEventArgs to retrieve data from and set data in the specified range. 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);
}

function ewaOnPageLoad() {
    if (typeof (Ewa) != "undefined") {
        Ewa.EwaControl.add_applicationReady(ewaApplicationReady);
    }
    else {
        alert("Error - the EWA JS is not loaded.");
    }
    // ...
}

function ewaApplicationReady() {
    // Get a reference to the Excel Services Web Part.
    ewa = Ewa.EwaControl.getInstances().getItem(0);
    // Add an event handler for the 
    // active cell changed event.
    ewa.add_commitCellEditing(ewaCommitCellEditing);

    // ...
}

function ewaCommitCellEditing(rangeEditArgs) {
    // Get the value of the cell before editing
    var oldValue = rangeEditArgs.getTargetOldUnformattedValue();
    // Get the value of the cell after editing
    var newValue = rangeEditArgs.getTargetUnformattedValue();

    // Display the before and after values of the cell
    alert("Old value: " + oldValue.toString() + "\nNew value: " + newValue.toString());

    var o = new Object();
    o = "Set via code";

    // Set the value of the cell programmatically 
    rangeEditArgs.setTargetUnformattedValue(o);
} // End ewaCommitCellEditing
</script>

Show:
© 2014 Microsoft