Ewa.NamedItem Object

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

Represents a named item.

Ewa.NamedItem

Remarks

Named items include named ranges, parameters, tables, PivotTables, and charts (including, PivotCharts and chart sheets). Named items do not include macro sheets.

Example

The following code example shows how to add a button to the page and then adds an event handler to the onClick method for the button. When the button is clicked, a message is displayed that specifies the NamedItemType of the active named item. 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);                                
}              
        
function getNamedItemTypeButton()
{    
    // Only run if in named item view.
    if (ewa.getActiveWorkbook().getIsNamedItemView())
    {   
        // Get the active Named Item.
        var namedItem = ewa.getActiveWorkbook().getActiveNamedItem();  
    
        var myType = null;
    
        // Determine the NamedItemType of the Named Item.
        switch(namedItem.getNamedItemType())
        {
            case Ewa.NamedItemType.NamedRange:
                myType = "NamedRange";
                break;
            case Ewa.NamedItemType.Parameter:
                myType = "Parameter";
                break;
            case Ewa.NamedItemType.Table:
                myType = "Table";
                break;
            case Ewa.NamedItemType.PivotTable:
                myType = "PivotTable";
                break;
            case Ewa.NamedItemType.Chart:  
                myType = "Chart";
                break;            
        }        
        // Display type of named item.
        alert("The active Named Item has a NamedItemType of " + myType + ".");
    }
    
    alert("Not in named item view.");
}

</script>
<input type="button" id="GetNamedItemType" value="Get Named Item Type" onclick="getNamedItemTypeButton()" />

See also

Concepts

Ewa.NamedItem Methods