Ewa.AsyncResult オブジェクト

**適用対象:**apps for SharePoint | Excel Services | SharePoint Server 2013

最初の引数として指定されたコールバックに渡さし、非同期の演算を行った結果を示します。

Ewa.AsyncResult

注釈

AsyncResultには、任意のエラー コード、エラー メッセージの場合は、操作が成功したかどうかを返す値、および状態の情報など、非同期操作に関する情報が含まれています。

Excel ServicesECMAScript (JavaScript, JScript)オブジェクト モデル] では、「非同期」(たとえば、Workbook.getRangeA1Async) を追加する方法の名前を持つすべてのメソッドは、指定したコールバック メソッドを引数としてAsyncResultオブジェクトを使用します。非同期の操作に関する情報を取得するのにには、 AsyncResultオブジェクトのメソッドを使用します。

次の例では、戻り値と getRangeA1Async メソッドの呼び出しの原因となった状態の情報を入手するAsyncResultオブジェクトを使用する方法を示します。

<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>

関連項目

参照先

Ewa.AsyncResult 方法