Ewa.AsyncResult Object

Applies to: apps for SharePoint | Excel Services | SharePoint Server 2013

Contains the result of the asynchronous operation and is passed as the first argument to the specified callback.

Ewa.AsyncResult

Remarks

AsyncResult contains information about the asynchronous operation, such as any error code, error message, whether the operation succeeded, return values, and state information.

In the Excel ServicesECMAScript (JavaScript, JScript) Object Model, all methods that have a method name that is appended with "Async" (for example, Workbook.getRangeA1Async) use an AsyncResult object as an argument in the call to the specified callback method. You use the methods of the AsyncResult object to retrieve information about the asynchronous operation.

Example

The following code example shows how to use the AsyncResult object to obtain the return value and state information that resulted from the call to the getRangeA1Async method.

<script type="text/javascript">

var ewa = null;

// Add event handler for onload event.
if (window.attachEvent) 
{ 
    window.attachEvent("onload", ewaOnPageLoad);    
} 
else 
{ 
    window.addEventListener("DOMContentLoaded", ewaOnPageLoad, false); 
}
// Add event handler to the applicationReady event.
function ewaOnPageLoad()
{
    if (typeof (Ewa) != "undefined")
    {
       Ewa.EwaControl.add_applicationReady(ewaApplicationReady);
    }
    else
    {
       alert("Error - the EWA is not loaded.");
    }
    // Add your code here.
}

function ewaApplicationReady()
{
    // Get a reference to the Excel Services Web Part.
    ewa = Ewa.EwaControl.getInstances().getItem(0);

    // Add your code here.
}

function someFunction()
{
   // Add your code here.
   ewa.getActiveWorkbook().getRangeA1Async("Sheet2!B2", getRangeComplete, userContext);
   // Add other code here.
}
function getRangeComplete(asyncResult)
{
    if (asyncResult.getSucceeded())
    {
        // Gets the value in "Sheet2!B2".
        var range = asyncResult.getReturnValue();
        // Gets the value of the argument passed in 
        // for the userContext parameter in getRangeA1Async.
        var value = asyncResult.getUserContext();
    }
    // Add your code here.
}
</script>

See also

Reference

Ewa.AsyncResult Methods