Last modified: June 14, 2011

Applies to: apps for SharePoint | SharePoint Server 2010

In this article
Return Value
Applies To

Gets the sheet collection.

var value = Ewa.Workbook.getSheets();

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 Note

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

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);    
    window.addEventListener("DOMContentLoaded", ewaOmPageLoad, false); 

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

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

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