Protection

Protection class

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

class Protection;

Example

const { Workbook } = AsposeCells;

var workbook = new Workbook();
var sheetIndex = workbook.worksheets.add();
var worksheet = workbook.worksheets.get(sheetIndex);
//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

PropertyTypeDescription
allowDeletingColumnbooleanRepresents if the deletion of columns is allowed on a protected worksheet.
allowDeletingRowbooleanRepresents if the deletion of rows is allowed on a protected worksheet.
allowFilteringbooleanRepresents if the user is allowed to make use of an AutoFilter that was created before the sheet was protected.
allowFormattingCellbooleanRepresents if the formatting of cells is allowed on a protected worksheet.
allowFormattingColumnbooleanRepresents if the formatting of columns is allowed on a protected worksheet
allowFormattingRowbooleanRepresents if the formatting of rows is allowed on a protected worksheet
allowInsertingColumnbooleanRepresents if the insertion of columns is allowed on a protected worksheet
allowInsertingHyperlinkbooleanRepresents if the insertion of hyperlinks is allowed on a protected worksheet
allowInsertingRowbooleanRepresents if the insertion of rows is allowed on a protected worksheet
allowSortingbooleanRepresents if the sorting option is allowed on a protected worksheet.
allowUsingPivotTablebooleanRepresents if the user is allowed to manipulate pivot tables on a protected worksheet.
allowEditingContentbooleanRepresents if the user is allowed to edit contents of locked cells on a protected worksheet.
allowEditingObjectbooleanRepresents if the user is allowed to manipulate drawing objects on a protected worksheet.
allowEditingScenariobooleanRepresents if the user is allowed to edit scenarios on a protected worksheet.
allowSelectingLockedCellbooleanRepresents if the user is allowed to select locked cells on a protected worksheet.
allowSelectingUnlockedCellbooleanRepresents if the user is allowed to select unlocked cells on a protected worksheet.
passwordstringRepresents the password to protect the worksheet.
isProtectedWithPasswordbooleanReadonly. Indicates whether the worksheets is protected with password.

Methods

MethodDescription
copy(Protection)Copy protection info.
verifyPassword(string)Verifies password.
getPasswordHash()Gets the hash of current password.

allowDeletingColumn

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

allowDeletingColumn : boolean;

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.

allowDeletingRow : boolean;

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.

allowFiltering

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

allowFiltering : boolean;

allowFormattingCell

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

allowFormattingCell : boolean;

allowFormattingColumn

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

allowFormattingColumn : boolean;

allowFormattingRow

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

allowFormattingRow : boolean;

allowInsertingColumn

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

allowInsertingColumn : boolean;

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

allowInsertingHyperlink : boolean;

allowInsertingRow

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

allowInsertingRow : boolean;

allowSorting

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

allowSorting : boolean;

allowUsingPivotTable

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

allowUsingPivotTable : boolean;

allowEditingContent

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

allowEditingContent : boolean;

allowEditingObject

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

allowEditingObject : boolean;

allowEditingScenario

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

allowEditingScenario : boolean;

allowSelectingLockedCell

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

allowSelectingLockedCell : boolean;

allowSelectingUnlockedCell

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

allowSelectingUnlockedCell : boolean;

password

Represents the password to protect the worksheet.

password : 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.

isProtectedWithPassword

Readonly. Indicates whether the worksheets is protected with password.

isProtectedWithPassword : boolean;

copy(Protection)

Copy protection info.

copy(source: Protection) : void;

Parameters:

ParameterTypeDescription
sourceProtection

verifyPassword(string)

Verifies password.

verifyPassword(password: string) : boolean;

Parameters:

ParameterTypeDescription
passwordstringThe password.

getPasswordHash()

Gets the hash of current password.

getPasswordHash() : number;