Export (0) Print
Expand All

Ewa.NamedItem Object

Last modified: June 13, 2011

Applies to: apps for SharePoint | SharePoint Server 2010

Represents a named item.


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

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);    
    window.addEventListener("DOMContentLoaded", ewaOmPageLoad, false); 

// Add event handler for applicationReady event.
function ewaOmPageLoad() 

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.
            case Ewa.NamedItemType.NamedRange:
                myType = "NamedRange";
            case Ewa.NamedItemType.Parameter:
                myType = "Parameter";
            case Ewa.NamedItemType.Table:
                myType = "Table";
            case Ewa.NamedItemType.PivotTable:
                myType = "PivotTable";
            case Ewa.NamedItemType.Chart:  
                myType = "Chart";
        // Display type of named item.
        alert("The active Named Item has a NamedItemType of " + myType + ".");
    alert("Not in named item view.");

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