Share via


Ewa.Workbook.getIsNamedItemView()

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

In this article
Return Value
Remarks
Example
Applies To

Gets a value that specifies if the Ewa.EwaControl is displayed in named item view.

var value = Ewa.Workbook.getIsNamedItemView();

Return Value

Type: Boolean

Remarks

The [Ewa.Workbook.getIsNamedItemView] method returns a Boolean value of true if the Ewa.EwaControl is displayed 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. The code example assumes that you are working with an Excel Web Access Web Part on SharePoint Server 2013.

<script type="text/javascript">
     
var ewa = null;
var itemCount = 1;
     
// 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 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