Ewa.Sheet.getSheetType()
Applies to: apps for SharePoint | SharePoint Server 2010
In this article
Return Value
Remarks
Example
Applies To
Gets the type of sheet.
var value = Ewa.Sheet.getSheetType();
Return Value
Remarks
The Ewa.Sheet.getSheetType method returns the type of sheet for the specified sheet. The Ewa.SheetType Enumeration contains 2 constants: Worksheet and Chart.
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 sheet type for the active sheet and then displays the sheet type 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 getSheetTypeButton()
{
// Get SheetType enumeration value.
var type = ewa.getActiveWorkbook().getActiveSheet().getSheetType();
// Get SheetType as a readable string.
var typeString = getSheetTypeAsString(type);
// Display sheet type in browser status bar.
window.status = "The active sheet SheetType is " + typeString + ".";
}
function getSheetTypeAsString(type)
{
var myType = null;
switch(type)
{
case Ewa.SheetType.Worksheet:
myType = "Worksheet";
break;
case Ewa.SheetType.Chart:
myType = "Chart";
break;
default:
myType = "undefined";
}
return myType;
}
</script>
<input type="button" id="GetSheetType" VALUE="Get Sheet Type" onclick="getSheetTypeButton()">