Ewa.Sheet.getVisible()

SharePoint 2013

Last modified: October 05, 2012

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

In this article
Return value
Remarks
Example

Gets a value that specifies whether the sheet is visible or not.

var value = Ewa.Sheet.getVisible();

The Ewa.Sheet.getVisible method returns a Ewa.SheetVisibility enumeration constant that indicates the level of visibility for the specified worksheet. The Ewa.SheetVisibility enumeration contains 3 constants: Visible, Hidden, and VeryHidden.

The following code example loops through all the worksheets in the workbook and displays the level of visibility for each sheet. 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(ewaApplicationReady); 
} 

function ewaApplicationReady()
{        
    // Get a reference to the Excel Services Web Part.
    ewa = Ewa.EwaControl.getInstances().getItem(0);  
    // Get a reference to the sheets collection
    var sheets = ewa.getActiveWorkbook().getSheets();
    var sheet;
    var visible, visibilityString;

    // Display the level of visibility for each sheet
    for (i = 0; i < sheets.getCount(); i++) {
        sheet = sheets.getItem(i);
        visible = sheet.getVisible();
        visibilityString = getSheetVisibilityAsString(visible);
        
        alert("The level of visibility for " + sheet.getName() + " is " + visibilityString + ".");
    } // End for loop                                     
}              


function getSheetVisibilityAsString(visible)
{
    var visibleType = null;
    
    switch(visible)
    {
        case Ewa.SheetVisibility.Hidden:
            visibleType = "Hidden";
            break;
        case Ewa.SheetVisibility.VeryHidden:
            visibleType = "VeryHidden";
            break;
        default:
            visibleType = "Visible";
    }        
    
    return visibleType;    
}

</script>

Show: