Class Protection
Contents
[
Hide
]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. |
| IsProtectedWithPassword { get; } | Indicates whether the worksheets is protected with password. |
| 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
namespace AsposeCellsExamples
{
using Aspose.Cells;
using System;
public class ProtectionDemo
{
public static void ProtectionExample()
{
// Instantiating a Workbook object
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
// Accessing the protection settings of the worksheet
Protection protection = worksheet.Protection;
// Setting various protection properties
protection.AllowDeletingColumn = true;
protection.AllowDeletingRow = true;
protection.AllowFiltering = true;
protection.AllowFormattingCell = true;
protection.AllowFormattingColumn = true;
protection.AllowFormattingRow = true;
protection.AllowInsertingColumn = true;
protection.AllowInsertingHyperlink = true;
protection.AllowInsertingRow = true;
protection.AllowSorting = true;
protection.AllowUsingPivotTable = true;
protection.AllowEditingContent = true;
protection.AllowEditingObject = true;
protection.AllowEditingScenario = true;
protection.Password = "password123";
protection.AllowSelectingLockedCell = true;
protection.AllowSelectingUnlockedCell = true;
// Checking if the worksheet is protected with a password
bool isProtectedWithPassword = protection.IsProtectedWithPassword;
// Saving the workbook
workbook.Save("ProtectionExample.xlsx");
return;
}
}
}
See Also
- namespace Aspose.Cells
- assembly Aspose.Cells