Ewa.EwaControl.add_activeCellChanged(function)

Applies to: apps for SharePoint | SharePoint Server 2010

In this article
Return Value
Remarks
Example

Subscribes an event handler to the [activeCellChanged] event.

Ewa.EwaControl.add_activeCellChanged(function);

Parameters

function

The event handler to subscribe to the event.

Return Value

None.

Remarks

The Ewa.EwaControl.add_activeSelectionChanged method subscribes an event handler to the activeCellChanged event. The activeCellChanged event fires when the active cell is changed (through mouse selection, cursor keys, return key, and so on).

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 activeCellChanged event is invoked, it is invoked with a single argument of type Ewa.RangeEventArgs. The Ewa.RangeEventArgs object contains information about the Ewa.Range object associated with the activeCellChanged event.

Example

The following code example subscribes an event handler to the activeCellChanged event. The code also shows how to use the Ewa.RangeEventArgs to get information about the specified range.

<script type="text/javascript">

var ewa = null;
// Add event handler for onload event.
if (window.attachEvent) 
{ 
    window.attachEvent("onload", ewaOmPageLoad);    
} 
else 
{ 
    window.addEventListener("DOMContentLoaded", ewaOmPageLoad, 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_activeCellChanged(cellChanged);

    // ...
}

// Handle the active cell changed event.
function cellChanged(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();
    alert("The active cell is located at row " + (row + 1) + " andcolumn " + (col + 1) + " with value " + value + ".");
    // ...
}

</script>

See Also

Reference

Ewa.EwaControl Object