With version 4.7.1.10 of Aspose.Cells.dll it worked to lock cells with the following code.
Aspose.Cells.Style style = workbook.Styles[workbook.Styles.Add()];
style.Font.Size = 10;
style.IsLocked = true;
style.Name = "ReadOnlyClass";
style = workbook.Styles[workbook.Styles.Add()];
style.Font.Size = 9;
style.IsLocked = false;
style.Name = "EditableClass";
range = sheet.Cells.CreateRange(0, 0, 2, 2);
styleFlag = new StyleFlag();
styleFlag.All = true;
range.ApplyStyle(workbook.Styles["ReadOnlyClass"], styleFlag);
range = sheet.Cells.CreateRange(3, 0, 2, 2);
styleFlag = new StyleFlag();
styleFlag.All = true;
range.ApplyStyle(workbook.Styles["EditableClass"], styleFlag);
sheet.Protection.IsDeletingColumnsAllowed = false;
sheet.Protection.IsDeletingRowsAllowed = false;
sheet.Protection.IsEditingContentsAllowed = false;
sheet.Protection.IsEditingObjectsAllowed = false;
sheet.Protection.IsEditingScenariosAllowed = false;
sheet.Protection.IsFilteringAllowed = false;
sheet.Protection.IsFormattingCellsAllowed = true;
sheet.Protection.IsFormattingColumnsAllowed = true;
sheet.Protection.IsFormattingRowsAllowed = true;
sheet.Protection.IsInsertingColumnsAllowed = false;
sheet.Protection.IsInsertingHyperlinksAllowed = false;
sheet.Protection.IsInsertingRowsAllowed = false;
sheet.Protection.IsSelectingLockedCellsAllowed = true;
sheet.Protection.IsSelectingUnlockedCellsAllowed = true;
sheet.Protection.IsSortingAllowed = false;
sheet.Protection.IsUsingPivotTablesAllowed = false;
sheet.Protection.Password = "hello";
Now with version 4.9.1.0 all cells i locked even the ones with the style EditableClass where style.IsLocked = false;
Please tell me how to only lock certain cells.
This message was posted using Aspose.Live 2 Forum