Last modified: June 08, 2011

Applies to: apps for SharePoint | SharePoint Server 2010

In this article
Return Value
Applies To

In Web Part mode, gets the root-level DOM element (HTTPDivElement) for the Excel Web Access Web Part.

var value = Ewa.EwaControl.getDomElement();

The EwaControl.getDomElement method returns an object that represents the HTTPDivElement that demarcates the Excel Web Access Web Part.

Once you have a reference to the div element that represents the Excel Web Access Web Part, you can perform document object model (DOM) manipulations on it.

The following code example shows how to use the EwaControl.getDomElement method to change the borders of the Excel Web Access Web Part that finishes recalculating first.

<script type="text/javascript"> 

// Set a flag for the EWA that recalculates first.
var firstToRecalc = false;

// Declare variables for each EWA.
var Ewa0 = null;
var Ewa1 = null;

// Add event handler for onload event.
if (window.attachEvent) 
    window.attachEvent("onload", ewaOmPageLoad);    
    window.addEventListener("DOMContentLoaded", ewaOmPageLoad, false); 

// Proceed to the GetEWA function once the Excel Services JSOM is ready.
function ewaOmPageLoad()

function onRecalc(asyncresult)
    // Use the user context here to get an instance of the EWA.
    currentEwa = asyncresult.getUserContext();

    // Get the root div element for the EWA.
    enclosingdiv = currentEwa.getDomElement();

    // Highlight the border of the first EWA to recalculate.
    if (firstToRecalc == false)
// Change the border of the EWA div.
enclosingdiv.style.border = "solid green 2px";
    // Toggle the flag.
    firstToRecalc = !firstToRecalc;

function getEwa()
    // Get a reference to the 2 EWAs.
    Ewa0 = Ewa.EwaControl.getInstances().getItem(0);
    Ewa1 = Ewa.EwaControl.getInstances().getItem(1);

    // Call recalcAsync on each EWA part.
    Ewa0.getActiveWorkbook().recalcAsync(onRecalc, Ewa0); // Note the Ewa instance is passed as the userContext.
    Ewa1.getActiveWorkbook().recalcAsync(onRecalc, Ewa1); // The same method is used for both EWAs.