Ewa.SheetCollection Object

Last modified: March 21, 2014

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

Represents a collection of sheets in a workbook.


The Ewa.SheetCollection represents all the sheet objects in a workbook, including chart sheets. This collection does not include macro sheets. The index is zero-based and does not have gaps. This collection is not accessible in named item view mode.

Note Note

The collection contains hidden sheets but these will not be returned if your permissions restrict you to viewing only published items.

The following code example shows how to add a button to the page and then adds code to the button onClick event that gets the number of sheets in the workbook and then displays the count 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 getSheetCountButton()
    // Get a reference to the active workbook.
    var workbook = ewa.getActiveWorkbook();   
    // Display the number of sheets in the active workbook.
    window.status = "The workbook has " + workbook.getSheets().getCount() + " worksheets.";

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