Ewa.Range.getColumn()
Applies to: apps for SharePoint | SharePoint Server 2010
In this article
Return Value
Remarks
Example
Applies To
Gets the column position on the zero-based grid.
var value = Ewa.Range.getColumn();
Return Value
int
Remarks
The Ewa.Range.getColumn method returns an integer value that represents the column position of the specified range. The column position is determined by the top-leftmost cell in the range and is zero-based; that is, column "A" is 0, column "B" is 1, and so on.
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()" />