Ewa.Workbook.add_sheetDataEntered(function)
Applies to: apps for SharePoint | Excel Services | SharePoint Server 2013
In this article
Return value
Remarks
Example
Subscribes an event handler to the sheetDataEntered event.
Ewa.Workbook.add_sheetDataEntered(function)
Parameters
function
The event handler to subscribe to the event.
Return value
None.
Remarks
The [Ewa.Workbook.add_sheetDataEntered] method subscribes an event handler to the [sheetDataEntered] event. The [sheetDataEntered] event fires when data is entered into a range (after pressing the enter key, tab key, or selecting a different cell or range) in any sheet in the workbook.
When the specified event handler for the [sheetDataEntered] event is invoked, it is invoked with a single argument of type Ewa.RangeChangeEventArgs. You can use the Ewa.RangeChangeEventArgs object to get references to the range, sheet, and workbook objects or to get formatted values from the range associated with the event. Additionally, you can use the Ewa.RangeChangeEventArgs to get a reference to the associated Excel Web Access Web Part.
Example
The following code example subscribes an event handler to the sheetDataEntered event. The code also shows how to use the Ewa.RangeChangeEventArgs object to get information about the specified range. 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;
// Run the Excel load handler on page load
if (window.attachEvent) {
window.attachEvent("onload", loadEwaOnPageLoad);
} else {
window.addEventListener("DOMContentLoaded", loadEwaOnPageLoad, false);
}
// Event handler for page load event
function loadEwaOnPageLoad() {
if (typeof (Ewa) != "undefined") {
// Retrieve workbook from SharePoint location when EWA is ready
Ewa.EwaControl.add_applicationReady(ewaApplicationReady);
}
else {
alert("Error - the EWA is not loaded.");
}
// ...
}
function ewaApplicationReady() {
// Get a reference to the EWA web part that represents the Ewa web part
// in SharePoint:
ewa = Ewa.EwaControl.getInstances().getItem(0);
// Add event handler for the sheetDataEntered event
ewa.getActiveWorkbook().add_sheetDataEntered(sheetDataEnteredHandler);
}
function sheetDataEnteredHandler(rangeChangeArgs) {
var sheetName = rangeChangeArgs.getRange().getSheet().getName();
var col = rangeChangeArgs.getRange().getColumn();
var row = rangeChangeArgs.getRange().getRow();
var value = rangeChangeArgs.getFormattedValues();
alert("The range was located at row " + (row + 1) + " and column " + (col + 1) + " with value " + "\"" + value + "\"" + ".");
}
</script>