Share via


Ewa.NamedItem Object

Applies to: apps for SharePoint | SharePoint Server 2010

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.

<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 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