Hi,
I'm working in Societe Generale and we need this functionality to purchase the licence.
What I'm doing :
1. Creation of a template ProtectSheetTemplate.xlsm in which I only allow users to edit ranges (Columns D and E)
2. In my code I open the template and apply protection (I'm not using the Protect method)
This is my code:
Workbook workbook = new Workbook();
string templateFileName = Environment.CurrentDirectory + "\\ProtectSheetTemplate.xlsm";
workbook.Open(templateFileName);
Worksheet worksheet = workbook.Worksheets[0];
worksheet.Protection.Password = "test";
worksheet.Protection.IsFilteringAllowed = true;
worksheet.Protection.IsSelectingLockedCellsAllowed = true;
worksheet.Protection.IsSelectingUnlockedCellsAllowed = true;
worksheet.Protection.IsDeletingColumnsAllowed = false;
worksheet.Protection.IsDeletingRowsAllowed = false;
worksheet.Protection.IsEditingContentsAllowed = false;
worksheet.Protection.IsEditingObjectsAllowed = false;
worksheet.Protection.IsEditingScenariosAllowed = false;
worksheet.Protection.IsFormattingCellsAllowed = false;
worksheet.Protection.IsFormattingColumnsAllowed = false;
worksheet.Protection.IsFormattingRowsAllowed = false;
worksheet.Protection.IsInsertingColumnsAllowed = false;
worksheet.Protection.IsInsertingHyperlinksAllowed = false;
worksheet.Protection.IsInsertingRowsAllowed = false;
worksheet.Protection.IsSortingAllowed = false;
worksheet.Protection.IsUsingPivotTablesAllowed = false;
workbook.Save(Environment.CurrentDirectory + "\\ProtectSheet.xls", FileFormatType.ExcelXP);
Even if I only open the template and save the file with another name, all the edit ranges I previously allowed have simply disappeared in the output document.
My template is in attach file:
Thanks for your response.
This message was posted using Page2Forum (attachment) from Advanced Protection Settings since Excel XP - Aspose.Cells for .NET