Class ProtectedRangeCollection
Contents
[
Hide
]ProtectedRangeCollection class
Encapsulates a collection of ProtectedRange
objects.
public class ProtectedRangeCollection : CollectionBase<ProtectedRange>
Properties
Name | Description |
---|---|
Capacity { get; set; } | |
Count { get; } | |
Item { get; } | Gets the ProtectedRange element at the specified index. |
Item { get; set; } |
Methods
Name | Description |
---|---|
Add(string, int, int, int, int) | Adds a ProtectedRange item to the collection. |
BinarySearch(ProtectedRange) | |
BinarySearch(ProtectedRange, IComparer<ProtectedRange>) | |
BinarySearch(int, int, ProtectedRange, IComparer<ProtectedRange>) | |
Clear() | |
Contains(ProtectedRange) | |
CopyTo(ProtectedRange[]) | |
CopyTo(ProtectedRange[], int) | |
CopyTo(int, ProtectedRange[], int, int) | |
Exists(Predicate<ProtectedRange>) | |
Find(Predicate<ProtectedRange>) | |
FindAll(Predicate<ProtectedRange>) | |
FindIndex(Predicate<ProtectedRange>) | |
FindIndex(int, Predicate<ProtectedRange>) | |
FindIndex(int, int, Predicate<ProtectedRange>) | |
FindLast(Predicate<ProtectedRange>) | |
FindLastIndex(Predicate<ProtectedRange>) | |
FindLastIndex(int, Predicate<ProtectedRange>) | |
FindLastIndex(int, int, Predicate<ProtectedRange>) | |
GetEnumerator() | |
IndexOf(ProtectedRange) | |
IndexOf(ProtectedRange, int) | |
IndexOf(ProtectedRange, int, int) | |
LastIndexOf(ProtectedRange) | |
LastIndexOf(ProtectedRange, int) | |
LastIndexOf(ProtectedRange, int, int) | |
RemoveAt(int) |
Examples
using System;
using Aspose.Cells;
namespace AsposeCellsExamples
{
public class CellsClassProtectedRangeCollectionDemo
{
public static void Run()
{
// Create a new workbook
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
// Get the protected range collection
ProtectedRangeCollection protectedRanges = worksheet.AllowEditRanges;
// Add a new protected range
int index = protectedRanges.Add("MyProtectedRange", 0, 0, 2, 2);
ProtectedRange protectedRange = protectedRanges[index];
protectedRange.Password = "1234";
// Add another protected range
index = protectedRanges.Add("AnotherRange", 3, 3, 5, 5);
protectedRange = protectedRanges[index];
protectedRange.Password = "5678";
// Display information about protected ranges
Console.WriteLine("Protected Ranges in Worksheet:");
foreach (ProtectedRange range in protectedRanges)
{
Console.WriteLine($"Name: {range.Name}");
Console.WriteLine($"Area: {range.CellArea.StartRow},{range.CellArea.StartColumn} to {range.CellArea.EndRow},{range.CellArea.EndColumn}");
Console.WriteLine($"Password Protected: {!string.IsNullOrEmpty(range.Password)}");
Console.WriteLine();
}
// Save the workbook
workbook.Save("ProtectedRangesDemo.xlsx");
}
}
}
See Also
- class CollectionBase<T>
- class ProtectedRange
- namespace Aspose.Cells
- assembly Aspose.Cells