Ewa.Workbook.refreshAllAsync(callback, userContext)

Applies to: apps for SharePoint | SharePoint Server 2010

In this article
Return Value
Remarks
Example

Refreshes all data connections in the workbook.

Ewa.Workbook.refreshAllAsync(callback, userContext);

Parameters

callback

The function that is called when the request is complete.

userContext

An object provided as a way for callers to pass state through the asynchronous call.

Return Value

None.

Remarks

The Ewa.Workbook.refreshAllAsync method refreshes data from external data sources that are connected to the workbook. Ewa.Workbook.refreshAllAsync has the same effect as refreshing all data connections.

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 refreshes all data connections for the workbook and then displays the success of the refresh operation 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 refreshAllAsyncButton()
{
    // Refresh all data connections.
    ewa.getActiveWorkbook().refreshAllAsync(refreshAllAsyncCallBack);
}     

function refreshAllAsyncCallBack(asyncResult)
{
    // Get the value from asyncResult if the asynchronous operation was successful.
    if (asyncResult.getCode() == 0)
    {
        // Display refresh success message.
        window.status = "Data connection refresh successful!";
    }
    else 
    {
         alert("Operation failed with error message " + asyncResult.getDescription() + ".");
    }    
} 

</script>
<input type="button" id="RefreshAllConns" value="Refresh Connections" onclick="refreshAllAsyncButton()" />

See Also

Reference

Ewa.Workbook Object