I am trying to have a worksheet with a read only range whilst the rest of the sheet is editable. I can get this by using the following code
Style readOnlyStyle = workBook.Styles[AsposeCellsConsts._READ_ONLY_RANGE_STYLE]
// create a new style if one does not already exist in this work book
if (readOnlyStyle == null)
{
readOnlyStyle = workBook.Styles[workBook.Styles.Add()] ;
readOnlyStyle.IsLocked = true ;
readOnlyStyle.Name = AsposeCellsConsts._READ_ONLY_RANGE_STYLE ;
}
StyleFlag readOnlyStyleFlag = new StyleFlag();
readOnlyStyleFlag.Locked = true;
range.ApplyStyle(workBook.Styles[AsposeCellsConsts._READ_ONLY_RANGE_STYLE], readOnlyStyleFlag) ;
workSheet.Protection.AllowEditingContent = false;
workSheet.Protection.AllowSelectingLockedCell = false;
workSheet.Protection.AllowSelectingUnlockedCell = true;
workSheet.Protection.Password = userPassword ;
If I use the above code then I have a worksheet with range read only and I cannot select the range which is what I want. I can edit the other cells of the worksheet which is alos what I want. However, the formulas do not work. I cannot sum cells either using the autosum function or maunally entering formula in the formula bar. If howver, I set the AlloweditingContent to true thrn that appears to override allowselectinglockedcell because I can now edit any fiel on the sheet including the locked cells and the formuals are now available.
In sumamry I want to be able to have the formulas available on the unlocked cells and the locked cells not to be selectable.