Free Support Forum - aspose.com

Cell protect

When a cell is protected ,others allow to be edited.Please tell me how to realize it ?

You can try 2 approaches:

1. In MS Excel, select all cells in a worksheet, uncheck "Locked" setting in "Format Cells..." window.

Next select a cell which you want to protect it, check "Locked" setting in "Format Cells..." window.

Finally, please protect this whole worksheet.

2. Using following code with Aspose.Cells:

Workbook excel = new Workbook();
excel.Worksheets[0].Cells["A1"].PutValue("hello");
Style style = excel.DefaultStyle;
style.IsLocked = false;
excel.DefaultStyle = style;
excel.Worksheets[0].Cells["A1"].Style.IsLocked = true;

excel.Worksheets[0].Protect(ProtectionType.All);

excel.Save("d:\\test\\abc.xls");

Thanks!