Ewa.Workbook Object

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

Represents an Excel workbook.

Ewa.Workbook

Remarks

The [Ewa.Workbook] represents the workbook associated with a given Ewa.EwaControl. Only one workbook can be associated with a Ewa.EwaControl.

Using the [Ewa.Workbook] object, you can get information about the user session, get information about the workbook itself, get references to the sheets collection and the named items collection, get the active cell, named item, sheet, or selection, and get ranges in the workbook. You can also force a recalculation on the workbook, refresh data connections, and set parameters on the workbook.

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);
}

// 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.
    Window.status = ewa.getActiveWorkbook().getWorkbookPath();
}
</script>

See also

Concepts

Ewa.Workbook Methods