Share via


Ewa.Workbook.getSheets()

Applies to: apps for SharePoint | SharePoint Server 2010

In this article
Return Value
Remarks
Example
Applies To

Gets the sheet collection.

var value = Ewa.Workbook.getSheets();

Return Value

SheetCollection

Remarks

The Ewa.Workbook.getSheets method returns the collection of sheets in the workbook as a SheetCollection object. Ewa.Workbook.getSheets returns null in named item view.

Note

Ewa.Workbook.getSheets only returns published and unhidden sheets.

Example

The following code example shows how to add a button to the page and then adds an event handler to the button onClick event that displays the total count of sheets in the workbook in an alert message.

<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);                                   
}              
// Add event handler for button onClick event.
function getSheetCountButton()
{
    // Get the Sheets collection.
    var sheets = ewa.getActiveWorkbook().getSheets();

    // Display count of sheets in workbook.
    alert("There are " + sheets.getCount() + " sheets.");    
}

</script>
<input type="button" id="GetSheetCount" value="Get Sheet Count" onclick="getSheetCountButton()" /> 

Applies To

Ewa.Workbook Object

See Also

Concepts

Ewa.Workbook Methods

Ewa Namespace