Free Support Forum - aspose.com

Locking worksheet and columns

Hi,


How to lock both worksheets and columns in an excel sheet using aspose. The code which you have mentioned in your website is not working …Can you please help me out…


worksheet.Cells[ColumnIndex].GetStyle().IsLocked=true;


Hi,


Please see the topic (especially the sub-topic i.e. “Protect a Column in the Worksheet”:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/protecting-worksheets.html

Thank you.

Hi ,

I want to lock the second column…but the code which i have written below is locking all the columns in the excel sheet except the second column…Please help me out…

Aspose.Cells.Style styleobj = new Aspose.Cells.Style();
styleobj = AsWorkSheetData.Cells.Columns[1].Style;
styleobj.IsLocked = false;

StyleFlag Flag=new StyleFlag();
Flag.Locked=true;

AsWorkSheetData.Cells.Columns[1].ApplyStyle(styleobj, Flag);

styleobj = AsWorkSheetData.Cells[1].GetStyle();
styleobj.IsLocked = true;

AsWorkSheetData.Protect(ProtectionType.All);