Share via


Ewa.SheetCollection.getCount()

Applies to: apps for SharePoint | SharePoint Server 2010

In this article
Return Value
Remarks
Example
Applies To

Gets the count of sheets in a workbook.

var value = Ewa.SheetCollection.getCount();

Return Value

integer

Remarks

The Ewa.SheetCollection.getCount method returns the number of sheets in the workbook. The count of sheets includes worksheets and chart 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.SheetCollection Object

See Also

Concepts

Ewa.SheetCollection Methods

Ewa Namespace