Class ProtectedRange
Contents
[
Hide
]ProtectedRange class
A specified range to be allowed to edit when the sheet protection is ON.
public class ProtectedRange
Properties
Name | Description |
---|---|
CellArea { get; } | Gets the CellArea object represents the cell area to be protected. |
IsProtectedWithPassword { get; } | Indicates whether the worksheets is protected with password. |
Name { get; set; } | Gets the Range title. This is used as a descriptor, not as a named range definition. |
Password { get; set; } | Represents the password to protect the range. |
SecurityDescriptor { get; set; } | The security descriptor defines user accounts who may edit this range without providing a password to access the range. |
Methods
Name | Description |
---|---|
AddArea(int, int, int, int) | Adds a referred area to this |
GetAreas() | Gets all referred areas. |
Examples
using System;
using Aspose.Cells;
namespace AsposeCellsExamples
{
public class CellsClassProtectedRangeDemo
{
public static void Run()
{
// Create a new workbook
Workbook workbook = new Workbook();
// Access the first worksheet
Worksheet worksheet = workbook.Worksheets[0];
// Get the collection of protected ranges
ProtectedRangeCollection protectedRanges = worksheet.AllowEditRanges;
// Add a new protected range (A1:J10)
int index = protectedRanges.Add("MyProtectedRange", 0, 0, 10, 10);
// Get the protected range
ProtectedRange protectedRange = protectedRanges[index];
// Set security descriptor
string securityDescriptor = "O:WDG:WDD:(D;;CC;;;S-1-5-21-2854911246-2539335229-2923752399-1000)(A;;CC;;;S-1-5-21-2854911246-2539335229-2923752399-1013)";
protectedRange.SecurityDescriptor = securityDescriptor;
// Save the workbook
workbook.Save("ProtectedRangeDemo.xlsx");
Console.WriteLine("Protected range demo completed successfully.");
}
}
}
See Also
- namespace Aspose.Cells
- assembly Aspose.Cells