Ewa.Range.getSheet()
Applies to: apps for SharePoint | SharePoint Server 2010
In this article
Return Value
Remarks
Example
Applies To
Gets the sheet in the workbook.
var value = Ewa.Range.getSheet();
Return Value
sheet
Remarks
The Ewa.Range.getSheet method returns a sheet object that represents the sheet where the specified range is located. Ewa.Range.getSheet returns null if the workbook is in named item view.
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 name of the worksheet where the selected range is located 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 getSheetNameButton()
{
// Get the active range.
var range = ewa.getActiveWorkbook().getActiveSelection();
if (range != null)
{
if (range.getSheet() != null)
{
// Display name of range worksheet.
window.status = "The selected range is on sheet " + range.getSheet().getName();
}
else
{
alert("Workbook is in named item view.");
}
}
else
{
alert("No range selected.");
}
}
</script>
<input type="button" id="ShowSheetName" value="Show Sheet Name" onclick="getSheetNameButton()" />