Ewa.Workbook.getActiveSelection()
Applies to: apps for SharePoint | SharePoint Server 2010
In this article
Return Value
Remarks
Example
Applies To
Gets the current selection as a range object.
var value = Ewa.Workbook.getActiveSelection();
Return Value
Remarks
The Ewa.Workbook.getActiveSelection method returns the current selection as a range. Ewa.Workbook.getActiveSelection returns null if no cell or cells on the grid are selected.
Example
The following code example shows how to add a button to the page and then adds an event handler to the button onClick event that displays the column position of the selected range in the browser status bar.
<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);
}
// Add event handler for applicationReady event.
function ewaOmPageLoad()
{
Ewa.EwaControl.add_applicationReady(getEwa);
}
function getEwa()
{
// Get a reference to the Excel Services Web Part.
ewa = Ewa.EwaControl.getInstances().getItem(0);
}
function getRangeColumnButton()
{
// Get the active range.
var range = ewa.getActiveWorkbook().getActiveSelection();
if (range != null)
{
// Display range column number.
window.status = "Column number of range: " + range.getColumn();
}
else
{
alert("No range selected.");
}
}
</script>
<input type="button" id="ShowRangeColumn" value="Show Range Column" onclick="getRangeColumnButton()" />