Class Protection

Class Protection

Namespace: Aspose.Cells
Assembly: Aspose.Cells.dll (25.2.0)

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

public class Protection

Inheritance

objectProtection

Inherited Members

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Examples

//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;
'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

Properties

AllowDeletingColumn

Represents if the deletion of columns is allowed on a protected worksheet.

public bool AllowDeletingColumn { get; set; }

Property Value

bool

Remarks

The columns containing the cells to be deleted must be unlocked when the sheet is protected, and “Select unlocked cells” option must be enabled.

AllowDeletingRow

Represents if the deletion of rows is allowed on a protected worksheet.

public bool AllowDeletingRow { get; set; }

Property Value

bool

Remarks

The rows containing the cells to be deleted must be unlocked when the sheet is protected, and “Select unlocked cells” option must be enabled.

AllowEditingContent

Represents if the user is allowed to edit contents of locked cells on a protected worksheet.

public bool AllowEditingContent { get; set; }

Property Value

bool

AllowEditingObject

Represents if the user is allowed to manipulate drawing objects on a protected worksheet.

public bool AllowEditingObject { get; set; }

Property Value

bool

AllowEditingScenario

Represents if the user is allowed to edit scenarios on a protected worksheet.

public bool AllowEditingScenario { get; set; }

Property Value

bool

AllowFiltering

Represents if the user is allowed to make use of an AutoFilter that was created before the sheet was protected.

public bool AllowFiltering { get; set; }

Property Value

bool

AllowFormattingCell

Represents if the formatting of cells is allowed on a protected worksheet.

public bool AllowFormattingCell { get; set; }

Property Value

bool

AllowFormattingColumn

Represents if the formatting of columns is allowed on a protected worksheet

public bool AllowFormattingColumn { get; set; }

Property Value

bool

AllowFormattingRow

Represents if the formatting of rows is allowed on a protected worksheet

public bool AllowFormattingRow { get; set; }

Property Value

bool

AllowInsertingColumn

Represents if the insertion of columns is allowed on a protected worksheet

public bool AllowInsertingColumn { get; set; }

Property Value

bool

AllowInsertingHyperlink

Represents if the insertion of hyperlinks is allowed on a protected worksheet

public bool AllowInsertingHyperlink { get; set; }

Property Value

bool

AllowInsertingRow

Represents if the insertion of rows is allowed on a protected worksheet

public bool AllowInsertingRow { get; set; }

Property Value

bool

AllowSelectingLockedCell

Represents if the user is allowed to select locked cells on a protected worksheet.

public bool AllowSelectingLockedCell { get; set; }

Property Value

bool

AllowSelectingUnlockedCell

Represents if the user is allowed to select unlocked cells on a protected worksheet.

public bool AllowSelectingUnlockedCell { get; set; }

Property Value

bool

AllowSorting

Represents if the sorting option is allowed on a protected worksheet.

public bool AllowSorting { get; set; }

Property Value

bool

AllowUsingPivotTable

Represents if the user is allowed to manipulate pivot tables on a protected worksheet.

public bool AllowUsingPivotTable { get; set; }

Property Value

bool

IsProtectedWithPassword

Indicates whether the worksheets is protected with password.

public bool IsProtectedWithPassword { get; }

Property Value

bool

Password

Represents the password to protect the worksheet.

public string Password { get; set; }

Property Value

string

Remarks

If password is set to null or blank string, you can unprotect the worksheet or workbook without using a password. Otherwise, you must specify the password to unprotect the worksheet or workbook.

Methods

Copy(Protection)

Copy protection info.

public void Copy(Protection source)

Parameters

source Protection

GetPasswordHash()

Gets the hash of current password.

public int GetPasswordHash()

Returns

int

VerifyPassword(string)

Verifies password.

public bool VerifyPassword(string password)

Parameters

password string

The password.

Returns

bool