Ewa.Workbook.getIsNamedItemView()

Applies to: apps for SharePoint | SharePoint Server 2010

In this article
Return Value
Remarks
Example
Applies To

Gets a value that specifies if the Excel Services Web Part is in named item view.

var value = Ewa.Workbook.getIsNamedItemView();

Return Value

Boolean

Remarks

The Ewa.Workbook.getIsNamedItemView method returns a Boolean value of true if the Excel Services Web Part is in named item view; otherwise, it returns false.

Example

The following code example shows how to add a button to the page. For each button click, the next named item in the collection of named items for the workbook is activated and a message is displayed in the browser status bar specifying the name of the activated named item.

<script type="text/javascript">
     
var ewa = null;
var itemCount = 1;
     
// 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 activateNamedItemsButton()
{    
    // Get a reference to the workbook.
    var wkBook = ewa.getActiveWorkbook();    
        
    // Only run if in Named Item view.
    if (wkBook.getIsNamedItemView())
    {
        // Get the collection of named items in the workbook.
        var items = wkBook.getNamedItems();
        // Get the next named item                
        var item = items.getItem(itemCount);
                
        itemCount++;
        
        if (itemCount >= items.getCount())
        {
            itemCount = 0;
        }        
        // Activate the specified named item.
        // Pass in named item as userContext.
        item.activateAsync(activateNamedItemsCallBack, item);
    }    
    else
    {
        alert("Not in NamedItem view.");
    }
}

// Get NamedItemType as string.
function getNamedItemTypeAsString(type)
{
    var myType = null;
    
    switch(type)
    {
        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;
        default:
            myType = "undefined";
    }        
    
    return myType;    
}
                
function activateNamedItemsCallBack(asyncResult)
{           
// Get named item from userContext.
    var item = asyncResult.getUserContext();  
    // Get NamedItemType as string.
    var type = getNamedItemTypeAsString(item.getNamedItemType());
    var output = "Named item with NamedItemType of " + type + " was activated.";
    
    // Display name of activated named item in browser status bar.
    window.status = output;    
}

</script>
<input type="button" id="ActivateNamedItems" value="Activate Named Items" onclick="activateNamedItemsButton()" />

Applies To

Ewa.Workbook Object

See Also

Concepts

Ewa.Workbook Methods

Ewa Namespace