Possible bug in Advanced Protection?

Hi,

I believe i have found a bug when adding advanced protection to a worksheet. If it isn't a bug id be interested in the explanation.

oWorksheet.Protection.IsDeletingColumnsAllowed = false;
oWorksheet.Protection.IsDeletingRowsAllowed = false;
//oWorksheet.Protection.IsEditingContentsAllowed = false;
oWorksheet.Protection.IsEditingObjectsAllowed = false;
oWorksheet.Protection.IsEditingScenariosAllowed = false;
oWorksheet.Protection.IsFilteringAllowed = false;
oWorksheet.Protection.IsFormattingCellsAllowed = false;
oWorksheet.Protection.IsFormattingColumnsAllowed = false;
oWorksheet.Protection.IsFormattingRowsAllowed = true;
oWorksheet.Protection.IsInsertingColumnsAllowed = false;
oWorksheet.Protection.IsInsertingHyperlinksAllowed = false;
oWorksheet.Protection.IsInsertingRowsAllowed = false;
oWorksheet.Protection.IsSelectingLockedCellsAllowed = true;
oWorksheet.Protection.IsSelectingUnlockedCellsAllowed = true;
oWorksheet.Protection.IsSortingAllowed = false;
oWorksheet.Protection.IsUsingPivotTablesAllowed = false;
oWorksheet.Protection.Password = "007";

I was having trouble figuring out why my protection settings were being set (actually in excel) yet were not taking effect. I copied the example given here:

<A href="https://forum.aspose.com/t/96575</A></P> <P>Which worked fine. I stripped my code down to the bare minimum to match this example and the only difference was the line commented out above. I had omitted that line in my code. Using the example again, i commented out the above line and found the protection does not get "invoked", just like my original problem. I thought maybe the protection requires every parameter to be set to be invoked but it seems omitting other paramaters does not cause any problems.

I look forward to your reply.

Regards,

Just to add i’m using the latest version 4.5.0.0

Hi ppsoftnet,

This is not a bug. This is actually how the MS Excel advance protection works. Let me explain it in a bit detail. The property you are commenting out "IsEditingContentsAllowed " is the main potection setting property and by default true in MS Excel which allows us to change all the contents of the sheet. All the remaining protection properties get invoked only if this property is set to false. So to make your worksheet protected you have to set this property to false.

If " IsEditingContentsAllowed " has a value true (By Default) that means "Protect worksheet and content of the locked cells" option will be unchecked in MS Excel and no protection will take effect.

If " IsEditingContentsAllowed " has a value false that means "Protect worksheet and content of the locked cells" option will be checked in MS Excel and it will allow the advance protection options to invoke.

For making it more clear please see the attached file which will give you a much clear picture of how MS Excel advance protection works.

MS Excel protection properties can be seen under Tools --> Protection

Best Regards,


Hi Alastair,

Thanks for your inquiry.

Well, Generally, Aspose.Cells follow MS Excel standards. I think you must have got the detailed explanation for your query now. Thank you Nausherwan for helping out the user.

Feel free to contact us any time if you need further assistance.

Thanks for the explanation Nausherwan