Free Support Forum -

Sheet protection

Instead of setting individual properties of a sheet to enable different functions, is there a way to unprotect the whole sheet programmatically ? I am using C# for my application. Currently I have only IsSortingAllowed set to true, but I would like to unprotect the whole sheet so that I can copy and paste other information into the same sheet.

Please try Worksheet.Unprotect method.

The Unprotect method does not seem to work for me (tried both overloads). I have to use the following code to be able to modify cells or copy and paste:

DataSheet.Protection.IsInsertingRowsAllowed = true;

DataSheet.Protection.IsInsertingColumnsAllowed = true;

DataSheet.Protection.IsFormattingColumnsAllowed = true;

DataSheet.Protection.IsFormattingCellsAllowed = true;

DataSheet.Protection.IsDeletingRowsAllowed = true;

DataSheet.Protection.IsEditingContentsAllowed = true;

Am I missing something ?

I misunderstood your need in earlier post.

Your code is correct. You have to set them one by one because they are independent properties. That's same as MS Excel.