Share via


Ewa.Range.getColumn()

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

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

Type: 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. 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(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()" />

Applies To

Ewa.Range Object

See also

Concepts

Ewa.Range Methods

Ewa namespace