Protection

Protection class

Represents the various types of protection options available for a worksheet.

public class Protection

Properties

Name Description
AllowDeletingColumn { get; set; } Represents if the deletion of columns is allowed on a protected worksheet.
AllowDeletingRow { get; set; } Represents if the deletion of rows is allowed on a protected worksheet.
AllowEditingContent { get; set; } Represents if the user is allowed to edit contents of locked cells on a protected worksheet.
AllowEditingObject { get; set; } Represents if the user is allowed to manipulate drawing objects on a protected worksheet.
AllowEditingScenario { get; set; } Represents if the user is allowed to edit scenarios on a protected worksheet.
AllowFiltering { get; set; } Represents if the user is allowed to make use of an AutoFilter that was created before the sheet was protected.
AllowFormattingCell { get; set; } Represents if the formatting of cells is allowed on a protected worksheet.
AllowFormattingColumn { get; set; } Represents if the formatting of columns is allowed on a protected worksheet
AllowFormattingRow { get; set; } Represents if the formatting of rows is allowed on a protected worksheet
AllowInsertingColumn { get; set; } Represents if the insertion of columns is allowed on a protected worksheet
AllowInsertingHyperlink { get; set; } Represents if the insertion of hyperlinks is allowed on a protected worksheet
AllowInsertingRow { get; set; } Represents if the insertion of rows is allowed on a protected worksheet
AllowSelectingLockedCell { get; set; } Represents if the user is allowed to select locked cells on a protected worksheet.
AllowSelectingUnlockedCell { get; set; } Represents if the user is allowed to select unlocked cells on a protected worksheet.
AllowSorting { get; set; } Represents if the sorting option is allowed on a protected worksheet.
AllowUsingPivotTable { get; set; } Represents if the user is allowed to manipulate pivot tables on a protected worksheet.
IsDeletingColumnsAllowed { get; set; } Represents if the deletion of columns is allowed on a protected worksheet.
IsDeletingRowsAllowed { get; set; } Represents if the deletion of rows is allowed on a protected worksheet.
IsEditingContentsAllowed { get; set; } Represents if the user is allowed to edit contents of locked cells on a protected worksheet.
IsEditingObjectsAllowed { get; set; } Represents if the user is allowed to manipulate drawing objects on a protected worksheet.
IsEditingScenariosAllowed { get; set; } Represents if the user is allowed to edit scenarios on a protected worksheet.
IsFilteringAllowed { get; set; } Represents if the user is allowed to make use of an AutoFilter that was created before the sheet was protected.
IsFormattingCellsAllowed { get; set; } Represents if the formatting of cells is allowed on a protected worksheet.
IsFormattingColumnsAllowed { get; set; } Represents if the formatting of columns is allowed on a protected worksheet
IsFormattingRowsAllowed { get; set; } Represents if the formatting of rows is allowed on a protected worksheet
IsInsertingColumnsAllowed { get; set; } Represents if the insertion of columns is allowed on a protected worksheet
IsInsertingHyperlinksAllowed { get; set; } Represents if the insertion of hyperlinks is allowed on a protected worksheet
IsInsertingRowsAllowed { get; set; } Represents if the insertion of rows is allowed on a protected worksheet
IsProtectedWithPassword { get; } Indicates whether the worksheets is protected with password.
IsSelectingLockedCellsAllowed { get; set; } Represents if the user is allowed to select locked cells on a protected worksheet.
IsSelectingUnlockedCellsAllowed { get; set; } Represents if the user is allowed to select unlocked cells on a protected worksheet.
IsSortingAllowed { get; set; } Represents if the sorting option is allowed on a protected worksheet.
IsUsingPivotTablesAllowed { get; set; } Represents if the user is allowed to manipulate pivot tables on a protected worksheet.
Password { get; set; } Represents the password to protect the worksheet.

Methods

Name Description
Copy(Protection) Copy protection info.
GetPasswordHash() Gets the hash of current password.
VerifyPassword(string) Verifies password.

Examples


[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();

Worksheet worksheet = workbook.Worksheets[0];
//Allowing users to select locked cells of the worksheet
worksheet.Protection.AllowSelectingLockedCell = true;
//Allowing users to select unlocked cells of the worksheet
worksheet.Protection.AllowSelectingUnlockedCell = true;  

[Visual Basic]

'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook()
Dim worksheet As Worksheet = workbook.Worksheets(0)
'Allowing users to select locked cells of the worksheet
worksheet.Protection.AllowSelectingLockedCell = True
'Allowing users to select unlocked cells of the worksheet
worksheet.Protection.AllowSelectingUnlockedCell = True

See Also