Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining


Last modified: October 03, 2012

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

In this article
Return Value

Subscribes an event handler to the [activeSelectionChanged] event.



The event handler to subscribe to the event.

The [Ewa.EwaControl.add_activeSelectionChanged] method subscribes an event handler to the [activeSelectionChanged] event. The [activeSelectionChanged] event is raised when the current selection is changed.

Note Note

The activeCellChanged event is distinct from the activeSelectionChanged event. The active cell is the cell that will receive input from the keyboard. The active selection is the range of cells that is currently selected. The active cell can change while the active range remains the same.

For example, when the Tab key is pressed within a selected range, the active cell changes but the selected range remains unchanged.

When the specified event handler for the [activeSelectionChanged] event is invoked, it is invoked with a single argument of type Ewa.RangeEventArgs. The [Ewa.RangeEventArgs] object contains information about the Ewa.Range associated with the [activeSelectionChanged] event.

The following code example subscribes an event handler to the [activeSelectionChanged] event. The code also shows how to use the [Ewa.RangeEventArgs] to get information about 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);

if (window.attachEvent)
    window.attachEvent("onload", ewaOnPageLoad);

// Add event handler for applicationReady event.
function ewaOnPageLoad()
    if (typeof (Ewa) != "undefined")
        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 
    // activeSelectionChanged event.
    // ...

// Handle the activeSelectionChanged event.
function selectionchanged(rangeArgs)
    // Use the RangeEventArgs object to get information about the range.
    var sheetName = rangeArgs.getRange().getSheet().getName();
    var col = rangeArgs.getRange().getColumn();
    var row = rangeArgs.getRange().getRow();
    var value = rangeArgs.getFormattedValues();


© 2015 Microsoft