Share via


Ewa.AsyncResult.getReturnValue()

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

この記事の内容
戻り値
注釈

呼び出された非同期メソッドの戻り値を取得します。

var value = Ewa.AsyncResult.getReturnValue();

戻り値

型: Object

注釈

**[AsyncResult]**オブジェクトは、非同期メソッドの呼び出しで指定されたコールバックに引数として渡されます。非同期メソッドは、戻り値を直接が、 **[AsynResult]オブジェクトにその戻り値を配置します。[AsyncResult.getReturnValue]**メソッドは、非同期操作の戻り値を取得します。

注意

戻り値の種類は、非同期操作によって返される型によって異なります。

次の例では、非同期操作の戻り値を取得する方法を示します。コードの例をExcel Web Access Web パーツでSharePoint Server 2013で作業していることを前提としています。

<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 for applicationReady event.
function ewaOnPageLoad() 
{         
    Ewa.EwaControl.add_applicationReady(getEwa); 
} 

function getEwa()
{
    // Get a reference to the Ewa object.
    ewa = Ewa.EwaControl.getInstances().getItem(0);
    getRangeAsync();
}

function getRangeAsync()
{
    // Get a range asynchronously using A1 notation.
    ewa.getActiveWorkbook().getRangeA1Async("Sheet3!B2", getRangeComplete, null);
}

function getRangeComplete(asyncResult)
{    
    // If getRangeA1Async failed, get error code.
    if (!asyncResult.getSucceeded())
    {
       // Get the error code.
        var errorCode = asyncResult.getCode();
        switch (errorCode)
        {
            case AsyncErrorCode.InternalError:
                alert("An internal error occurred.");
                break;
            case AsyncErrorCode.TimedOut:
                alert("The operation timed out.");
                break;            
            case AsyncErrorCode.InvalidNamedItem:
                alert("The named item is undefined or unpublished.");
                break;
            case AsyncErrorCode.SettingValuesError:
                alert("Excel Calculation Services is unable to set the values.");
                break;
            case AsyncErrorCode.RangeSizeError:
                alert("The array indices exceed the range columns and/or rows. Or the range columns and/or rows exceed the array indices.");
                break;            
        } // End switch.
    } // End if.
    
    // Get the range object from the getRangeA1Async call.
    var range = asyncResult.getReturnValue();
       
    // Display the range address in A1 format.
    window.status = range.getAddressA1();
}

</script>

関連項目

参照先

Ewa.AsyncResult 方法

概念

Ewa 名前空間