Share via


Ewa.EwaControl.getActiveWorkbook()

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

In this article
Return Value
Remarks
Example
Applies To

Gets the workbook associated with the specified EwaControl object.

var value = Ewa.EwaControl.getActiveWorkbook();

Return Value

Workbook

Remarks

Each EwaControl is associated with only one workbook. The EwaControl.getActiveWorkbook method returns the workbook associated with the specified EwaControl object.

Example

The following code example shows how to get the path for the workbook using the EwaControl.getActiveWorkbook method when the applicationReady event is raised and then displays the workbook path in an alert message. 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;
    
// 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()
    {
        if (typeof (Ewa) != "undefined")
        {
            Ewa.EwaControl.add_applicationReady(ewaApplicationReady);
        }
        else
        {
            alert("Error - the EWA JS is not loaded.");
        }
    }

    function ewaApplicationReady()
    {
    // Get a reference to the EWA.
        ewa = Ewa.EwaControl.getInstances().getItem(0);
        // Display the Workbook path.
    alert(ewa.getActiveWorkbook().getWorkbookPath());
    }
</script>

Applies To

Ewa.EwaControl Object

See also

Concepts

Ewa.EwaControl Methods

Ewa namespace