Share via


Ewa.NamedItem.getName()

Applies to: apps for SharePoint | SharePoint Server 2010

In this article
Return Value
Remarks
Example
Applies To

Gets the defined name of the named item.

var value = Ewa.NamedItem.getName();

Return Value

string

Remarks

The getName method returns the name of the specified named item as a string. The name of the named item is defined in the workbook.

Example

The following code example shows how to loop through all the named items in the workbook and displays the name of each name item in an alert message.

<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 getNamedItemsNamesButton()
{    
    // Get the specified workbook.
    var wkBook = ewa.getActiveWorkbook();    
    // Get the NamedItems collection.
    var items = wkBook.getNamedItems();
    
    for (i=0;i<items.getCount();i++)
    {
        alert(items.getItem(i).getName());
    }
}

</script>
<input type="button" id="GetNamedItemsNames" value="Get Named Items Names" onclick="getNamedItemsNamesButton()" /> 

Applies To

Ewa.NamedItem Object

See Also

Concepts

Ewa.NamedItem Methods

Ewa Namespace