Ewa.NamedItemCollection.getCount()

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

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. 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(onApplicationReady); 
} 

function onApplicationReady()
{        
    // 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