Share via


Ewa.Range.activateAsync(activeCellOffsetX, activeCellOffsetY, callback, userContext)

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

In this article
Return Value
Remarks
Example

Activates and selects a range.

Ewa.Range.activateAsync(activeCellOffsetX, activeCellOffsetY, callback, userContext);

Parameters

activeCellOffsetX

The number of cells to move horizontally away from the top-left cell (or top-right for right-to-left (RTL) locales) of the range.

activeCellOffsetY

The number of cells to move vertically away from the top-left cell (or top-right for RTL locales) in the range.

callback

The function that is called when the request is completed.

userContext

An object provided as a way for callers to pass state through the asynchronous call.

Return Value

None

Remarks

The Ewa.Range.activateAsync method activates the specified range and then selects a cell within that range. The worksheet containing this range is brought into view and the range is brought in view; however, Ewa.Range.activateAsync does not place the range in front of any overlapping objects if the range has overlapping objects. This method is not supported in named item view if the range is not a published named item.

The cell to be activated is specified by a positive offset from the top-left cell (top-right for RTL locales) of the range. The cell to be activated must be inside the range; otherwise the Ewa.Range.activateAsync method call will set the top-left (top-right for RTL locales) cell of the range as the active cell.

Example

The following code example shows how to get a range ("B2:C5") from worksheet "mySheet", activates the range, selects a cell ("B4") within the range, and then displays the success of the Ewa.Range.activateAsync method call in the browser status bar. The code example assumes that you are working with Excel Web Access Web Parts 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() 
{ 
Ewa.EwaControl.add_applicationReady(onApplicationReady); 
} 

function onApplicationReady()
{        
    // Get a reference to the Excel Services Web Part.
    ewa = Ewa.EwaControl.getInstances().getItem(0); 
    
    // Get range "B2:C5" from sheet, "mySheet".
    var range = ewa.getActiveWorkbook().getRange('mySheet',1,1,4,2);
    
    // Activate range and select cell "B4" (offset 0 (column)
    // and 2 (row)) from top-left of range.
    range.activateAsync(0,2,callhere, null);                                  
}         
 
function callhere(AsyncResult)
{
    // Display success of async call in browser status bar.
    window.status = 'Range is now active:' + AsyncResult.getSucceeded();
}
</script>

See also

Reference

Ewa.Range Object