Back to Devexpress

Worksheet.Visible Property

officefileapi-devexpress-dot-spreadsheet-dot-worksheet-c62912cc.md

latest8.9 KB
Original Source

Worksheet.Visible Property

Gets or sets whether the current worksheet is visible or hidden.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
bool Visible { get; set; }
vb
Property Visible As Boolean

Property Value

TypeDescription
Boolean

true , if the worksheet is visible; otherwise, false.

|

Remarks

Use the Visible property to control the visibility of the worksheet. To hide and unhide a worksheet, you can also use the Worksheet.VisibilityType property. It allows you to mark a worksheet as “very hidden”. In this mode, the worksheet cannot be accessed by end-users.

If you hide a worksheet that is currently active, the next visible worksheet to the right of this worksheet is automatically activated. If there are no visible worksheets to the right of the hidden worksheet, the first visible worksheet to the left of this worksheet becomes active.

Note

A workbook must always contain at least one visible worksheet.

Example

This example demonstrates how to manage worksheet visibility in a workbook. To do this, use the following properties.

Note

A workbook must always contain at least one visible worksheet.

View Example

csharp
// Hide the worksheet under the "Sheet2" name and prevent end-users from unhiding it via user interface.
// To make this worksheet visible again, use the Worksheet.Visible property.
workbook.Worksheets["Sheet2"].VisibilityType = WorksheetVisibilityType.VeryHidden;

// Hide the "Sheet3" worksheet. 
// In this state a worksheet can be unhidden via user interface.
workbook.Worksheets["Sheet3"].Visible = false;
vb
' Hide the worksheet under the "Sheet2" name and prevent end-users from unhiding it via user interface.
' To make this worksheet visible again, use the Worksheet.Visible property.
workbook.Worksheets("Sheet2").VisibilityType = WorksheetVisibilityType.VeryHidden

' Hide the "Sheet3" worksheet. 
' In this state a worksheet can be unhidden via user interface.
workbook.Worksheets("Sheet3").Visible = False

The following code snippets (auto-collected from DevExpress Examples) contain references to the Visible property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

spreadsheet-document-api-examples-part2/CS/SpreadsheetDocServerAPIPart2/CodeExamples/ProtectionActions.cs#L27

csharp
worksheet["B2"].Value = "Workbook structure is protected with a password. \n You cannot add, move or delete worksheets until protection is removed.";
worksheet.Visible = true;
#endregion #ProtectWorkbook

winforms-spreadsheetcontrol-api-part-2/CS/SpreadsheetControl_API_Part02/SpreadsheetActions/ProtectionActions.cs#L25

csharp
workbook.Protect("password", true, false);
workbook.Worksheets[0].Visible = false;
Worksheet worksheet = workbook.Worksheets[1];

wpf-spreadsheetcontrol-api-part-2/CS/SpreadsheetControl_WPF_API_Part02/SpreadsheetActions/ProtectionActions.cs#L23

csharp
workbook.Protect("password", true, false);
workbook.Worksheets[0].Visible = false;
Worksheet worksheet = workbook.Worksheets[1];

winforms-spreadsheetcontrol-api-part1/CS/SpreadsheetControl/SpreadsheetActions/WorksheetActions.cs#L106

csharp
// In this state, the worksheet can be unhidden via the user interface.
workbook.Worksheets["Sheet3"].Visible = false;
#endregion #ShowHideWorksheet

wpf-spreadsheetcontrol-api-part-1/CS/SpreadsheetControl_WPF_API/SpreadsheetActions/WorksheetActions.cs#L123

csharp
// In this state, the worksheet can be unhidden via the user interface.
workbook.Worksheets["Sheet3"].Visible = false;
#endregion #ShowHideWorksheet

spreadsheet-document-api-examples-part2/VB/SpreadsheetDocServerAPIPart2/CodeExamples/ProtectionActions.vb#L25

vb
worksheet("B2").Value = "Workbook structure is protected with a password. " & vbLf & " You cannot add, move or delete worksheets until protection is removed."
            worksheet.Visible = True
' #End Region ' #ProtectWorkbook

winforms-spreadsheetcontrol-api-part-2/VB/SpreadsheetControl_API_Part02/SpreadsheetActions/ProtectionActions.vb#L29

vb
End If
workbook.Worksheets(0).Visible = False
Dim worksheet As Worksheet = workbook.Worksheets(1)

wpf-spreadsheetcontrol-api-part-2/VB/SpreadsheetControl_WPF_API_Part02/SpreadsheetActions/ProtectionActions.vb#L27

vb
End If
workbook.Worksheets(0).Visible = False
Dim worksheet As Worksheet = workbook.Worksheets(1)

winforms-spreadsheetcontrol-api-part1/VB/SpreadsheetControl/SpreadsheetActions/WorksheetActions.vb#L108

vb
' In this state, the worksheet can be unhidden via the user interface.
            workbook.Worksheets("Sheet3").Visible = False
' #End Region ' #ShowHideWorksheet

wpf-spreadsheetcontrol-api-part-1/VB/SpreadsheetControl_WPF_API/SpreadsheetActions/WorksheetActions.vb#L112

vb
' In this state, the worksheet can be unhidden via the user interface.
            workbook.Worksheets("Sheet3").Visible = False
' #End Region ' #ShowHideWorksheet

See Also

VisibilityType

How to: Access a Worksheet

How to: Add a New Worksheet

How to: Delete a Worksheet

Worksheets in Spreadsheet Documents

Worksheet Interface

Worksheet Members

DevExpress.Spreadsheet Namespace