Share via


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

In this article
Return Value
Applies To

Gets the Ewa.Sheet with the matching name.

var value = Ewa.SheetCollection.getItemByName(name);



The display name of the worksheet.

Return Value

Type: Ewa.Sheet


The Ewa.SheetCollection.getItemByName method returns the specified sheet using its display name.


The following code example shows how to add a button to the page and then adds an event handler for the button onClick event that activates a worksheet, "Sheet3", using its display name and then displays the worksheet name in the browser status bar. 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;
// Add event handler for onload event.
if (window.attachEvent) 
    window.attachEvent("onload", ewaOnPageLoad);    
    window.addEventListener("DOMContentLoaded", ewaOnPageLoad, false); 

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

function onApplicationReady()
    // Get a reference to the Excel Services Web Part.
    ewa = Ewa.EwaControl.getInstances().getItem(0);                                   
function activateSheetButton()
    // Get a reference to the workbook.
    var wkBook = ewa.getActiveWorkbook();    
    // Get the collection of named items in the workbook.
    var sheets = wkBook.getSheets();
    // Get the next sheet                
        var sheet = sheets.getItemByName('Sheet3');                
    // Activate the specified sheet.
    // Pass in sheet as user context.
    sheet.activateAsync(activateSheetCallBack, sheet);    

function activateSheetCallBack(asyncResult)
    // Get the activated sheet from user context.
    var activatedSheet = asyncResult.getUserContext();
    // Display name of activated sheet in browser status bar.
    window.status = "Sheet " + activatedSheet.getName() + " was activated.";    

<input type="button" id="ActivateSheet" value="Activate Sheet" onclick="activateSheetButton()" />

Applies To

Ewa.SheetCollection Object

See also


Ewa.SheetCollection Methods

Ewa namespace