Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

Use the Excel Export API to Hide a Worksheet

  • 2 minutes to read

The example below demonstrates how to manage worksheet visibility in a workbook. To do this, use the IXlSheet.VisibleState property.

Set this property to the XlSheetVisibleState.Hidden value to hide a worksheet. End-users can show a hidden worksheet from the user interface (for example, when opening a workbook in Microsoft® Excel®). If you wish to prevent end-users from displaying hidden worksheets, mark a worksheet as “very hidden” by setting the IXlSheet.VisibleState property to XlSheetVisibleState.VeryHidden.

To restore the worksheet visibility, set the IXlSheet.VisibleState property to the XlSheetVisibleState.Visible enumeration member.

Important

A workbook must always contain at least one visible worksheet.

View Example

// Create the first worksheet. 
using (IXlSheet sheet = document.CreateSheet()) {
    sheet.Name = "Sales report";
}

// Create the second worksheet and specify its visibility.
using (IXlSheet sheet = document.CreateSheet()) {
    sheet.Name = "Sales data";
    sheet.VisibleState = XlSheetVisibleState.Hidden;
}

The image below shows the result. The “Sales data” worksheet is hidden, but its visibility can be restored by an end-user from the user interface (the document is opened in Microsoft® Excel®).

XLExport_Examples_HideSheet