Share via


Ewa.SheetCollection.getItemByName(name)

Applies to: apps for SharePoint | SharePoint Server 2010

In this article
Return Value
Remarks
Example
Applies To

Gets the sheet with the matching name.

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

Parameters

name

The display name of the worksheet.

Return Value

sheet

Remarks

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

Example

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.

<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 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.";    
}

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

Applies To

Ewa.SheetCollection Object

See Also

Concepts

Ewa.SheetCollection Methods

Ewa Namespace