Ewa.Workbook.getMode()

Last modified: June 14, 2011

Applies to: apps for SharePoint | SharePoint Server 2010

In this article
Return Value
Remarks
Example
Applies To

Gets the session mode; that is, whether the session is in view mode or edit mode.

var value = Ewa.Workbook.getMode();

The Ewa.Workbook.getMode method returns a SessionMode enumeration constant that indicates the session mode.

The following code example shows how to display the session mode in the browser status bar after the page loads.

<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);
    
    var mode = ewa.getActiveWorkbook().getMode(); 
    window.status =  "The session is in " + getSessionModeAsString(mode) + " mode.";                                
}              
      
// Get SessionMode as string.
function getSessionModeAsString(mode)
{
    var myMode = null;
    
    switch(mode)
    {
        case Ewa.SessionMode.View:
            myMode = "View";
            break;
        case Ewa.SessionMode.Edit:
            myMode = "Edit";
            break;
        default:
            myMode = "undefined";
    }        
    
    return myMode;    
}                 

</script>

Show: