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
Property | Type | Description |
---|---|---|
allowDeletingColumn | boolean | Represents if the deletion of columns is allowed on a protected worksheet. |
allowDeletingRow | boolean | Represents if the deletion of rows is allowed on a protected worksheet. |
allowFiltering | boolean | Represents if the user is allowed to make use of an AutoFilter that was created before the sheet was protected. |
allowFormattingCell | boolean | Represents if the formatting of cells is allowed on a protected worksheet. |
allowFormattingColumn | boolean | Represents if the formatting of columns is allowed on a protected worksheet |
allowFormattingRow | boolean | Represents if the formatting of rows is allowed on a protected worksheet |
allowInsertingColumn | boolean | Represents if the insertion of columns is allowed on a protected worksheet |
allowInsertingHyperlink | boolean | Represents if the insertion of hyperlinks is allowed on a protected worksheet |
allowInsertingRow | boolean | Represents if the insertion of rows is allowed on a protected worksheet |
allowSorting | boolean | Represents if the sorting option is allowed on a protected worksheet. |
allowUsingPivotTable | boolean | Represents if the user is allowed to manipulate pivot tables on a protected worksheet. |
allowEditingContent | boolean | Represents if the user is allowed to edit contents of locked cells on a protected worksheet. |
allowEditingObject | boolean | Represents if the user is allowed to manipulate drawing objects on a protected worksheet. |
allowEditingScenario | boolean | Represents if the user is allowed to edit scenarios on a protected worksheet. |
allowSelectingLockedCell | boolean | Represents if the user is allowed to select locked cells on a protected worksheet. |
allowSelectingUnlockedCell | boolean | Represents if the user is allowed to select unlocked cells on a protected worksheet. |
password | string | Represents the password to protect the worksheet. |
isProtectedWithPassword | boolean | Readonly. Indicates whether the worksheets is protected with password. |
Methods
Method | Description |
---|---|
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;
allowInsertingHyperlink
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:
Parameter | Type | Description |
---|---|---|
source | Protection |
verifyPassword(string)
Verifies password.
verifyPassword(password: string) : boolean;
Parameters:
Parameter | Type | Description |
---|---|---|
password | string | The password. |
getPasswordHash()
Gets the hash of current password.
getPasswordHash() : number;