SheetProtection
public sealed class SheetProtection
Namespace SharpCell · package SharpCell
What users may still do on a protected sheet, as Excel's Protect Sheet dialog lists it: by default they may select cells and nothing else. Set properties in an initializer and pass the object to Worksheet.Protect. Excel enforces the protection; SharpCell only keeps and saves it.
Constructors
SheetProtection()
public SheetProtection()
A protection allowing users to select cells and nothing else; set properties in an initializer.
SheetProtection(SheetProtection)
public SheetProtection(SheetProtection source)
A copy of another protection, so it can be changed in an initializer: new SheetProtection(sheet.Protection) { Sort = true }.
Parameters
source: The protection to copy.
Exceptions
ArgumentNullException: The source is null.
Properties
AutoFilter
public bool AutoFilter { get; init; }
Whether users may use AutoFilter; false unless set.
DeleteColumns
public bool DeleteColumns { get; init; }
Whether users may delete columns; false unless set.
DeleteRows
public bool DeleteRows { get; init; }
Whether users may delete rows; false unless set.
EditObjects
public bool EditObjects { get; init; }
Whether users may edit objects such as shapes and charts; false unless set.
EditScenarios
public bool EditScenarios { get; init; }
Whether users may edit scenarios; false unless set.
FormatCells
public bool FormatCells { get; init; }
Whether users may format cells; false unless set.
FormatColumns
public bool FormatColumns { get; init; }
Whether users may format columns, their widths and hiding included; false unless set.
FormatRows
public bool FormatRows { get; init; }
Whether users may format rows, their heights and hiding included; false unless set.
InsertColumns
public bool InsertColumns { get; init; }
Whether users may insert columns; false unless set.
InsertHyperlinks
public bool InsertHyperlinks { get; init; }
Whether users may insert hyperlinks; false unless set.
InsertRows
public bool InsertRows { get; init; }
Whether users may insert rows; false unless set.
PivotTables
public bool PivotTables { get; init; }
Whether users may use PivotTables and PivotCharts; false unless set.
SelectLockedCells
public bool SelectLockedCells { get; init; }
Whether users may select locked cells; true unless set.
SelectUnlockedCells
public bool SelectUnlockedCells { get; init; }
Whether users may select unlocked cells; true unless set.
Sort
public bool Sort { get; init; }
Whether users may sort; false unless set.
Methods
Equals(SheetProtection)
public bool Equals(SheetProtection? other)
Whether the other protection allows the same actions.
Equals(object)
public override bool Equals(object? obj)
Whether obj is a protection allowing the same actions.
GetHashCode()
public override int GetHashCode()
A hash code consistent with SheetProtection.Equals.
ToString()
public override string ToString()
The names of the allowed actions, such as SelectLockedCells, SelectUnlockedCells, or None.