Ewa.Workbook.getMode()

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

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

Return Value

Type: Ewa.SessionMode Enumeration

Remarks

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

Example

The following code example shows how to display the session mode in the browser status bar after the page loads. 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() 
{         
    Ewa.EwaControl.add_applicationReady(onApplicationReady); 
} 

function onApplicationReady()
{            
    // 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>

Applies To

Ewa.Workbook Object

See also

Concepts

Ewa.Workbook Methods

Ewa namespace