Ewa.SheetCollection Object
Applies to: apps for SharePoint | SharePoint Server 2010
Represents a collection of sheets in a workbook.
Ewa.SheetCollection
Remarks
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
The collection contains hidden sheets but these will not be returned if your permissions restrict you to viewing only published items.
Example
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.
<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 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.";
}
</script>
<input type="button" id="GetSheetCount" VALUE="Get Sheet Count" onclick="getSheetCountButton()">