Share via


Ewa.NamedItemCollection.getCount()

Applies to: apps for SharePoint | SharePoint Server 2010

In this article
Return Value
Remarks
Example
Applies To

Gets the count of all the named items in the specified workbook.

var value = Ewa.NamedItemCollection.getCount();

Return Value

int

Remarks

The getCount method returns the count of all the named items in the workbook.

Example

The following code example shows how to add a button to the page and then adds an event handler for the button onClick event that displays an alert message that indicates the total number of named items in the workbook.

<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);                                   
}              

// Add event handler for button onClick event.
function getCountOfNamedItems()
{
    // Get the NamedItems collection.
    var items = ewa.getActiveWorkbook().getNamedItems();

    // Display count of named items in workbook.
    alert("There are " + items.getCount() + " named items.");    
}

</script>
<input type="button" id="GetItemsCount" value="Get count of named items" getCountOfNamedItems()" /> 

Applies To

Ewa.NamedItemCollection Object

See Also

Concepts

Ewa.NamedItemCollection Methods

Ewa Namespace