Share via


Ewa.Range.getColumnCount()

Applies to: apps for SharePoint | SharePoint Server 2010

In this article
Return Value
Remarks
Example
Applies To

Gets the number of columns.

var value = Ewa.Range.getColumnCount();

Return Value

int

Remarks

The Ewa.Range.getColumnCount method returns an integer value that represents the number of columns in the specified range.

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 number of columns in 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 getRangeColumnCountButton()
{
    // Get the active range.
    var range = ewa.getActiveWorkbook().getActiveSelection();
    
    if (range != null)
    {
    // Display range column count.
    window.status = "Number of columns in range: " + range.getColumnCount(); 
    }    
    else
    {
       alert("No range selected.");
    }    
}            

</script>
<input type="button" id="ShowRangeColumnCount" value="Show Range Column Count" onclick="getRangeColumnCountButton()" />

Applies To

Ewa.Range Object

See Also

Concepts

Ewa.Range Methods

Ewa Namespace