How to Use Worksheet Protection Properties In ExcelWriter
In ExcelWriter 8.6.1, the ability to set specific worksheet protection properties was added with the new Sheet Protection Object. Worksheet Protection Properties allow the user to add permissions to do certain actions on protected worksheets.
The Excel Protection Properties
Excel Worksheet Protection Property | ExcelWriter SheetProtection Object Property |
---|---|
Select Locked cells | SheetProtection.AllowSelectLockedCells |
Select Unlocked Cells | SheetProtection.AllowSelectUnlockedCells |
Format Cells | SheetProtection.AllowFormatCells |
Format columns | SheetProtection.AllowFormatColumns |
Format Rows | SheetProtection.AllowFormatRows |
Insert Columns | SheetProtection.AllowInsertColumns |
Insert Rows | SheetProtection.AllowInsertRows |
Insert Hyperlinks | SheetProtection.AllowInsertHyperlinks |
Delete Columns | SheetProtection.AllowDeleteColumns |
Delete Rows | SheetProtection.AllowDeleteRows |
Sort | SheetProtection.AllowSort |
Use Autofilter | SheetProtection.AllowUseAutoFilter |
Use PivotTable reports | SheetProtection.AllowUsePivotTableReports |
Edit Objects | Not Supported by ExcelWriter |
Edit Scenarios | Not Supported by ExcelWriter |
Protection Properties Limitations
Microsoft Excel has a limitation on four of the protection properties: AllowSort, AllowDeleteColumns, AllowDeleteRows, and AllowInsertHyperlinks. These properties require that affected cells be editable when the worksheet is locked. This is because these properties entirely remove cells or alter the content of cells that are protected. Therefore, in order to use the properties you must unlock cells, put cells in an editable range, or use a macro.
Using the Protection Properties in Excel Writer
Steps to Use Protection Properties in ExcelWriter:
- Create a new sheet protection object
- Set the worksheet protection properties as desired. By default, Select Locked cells and Select Unlocked Cells are set to true
- Call Protect() on the worksheet Continue reading How to Use Worksheet Protection Properties In ExcelWriter