Hi,
Thanks for considering Aspose.
Well Yes, you can lock a cell, a complete row or a complete column in the worksheet easily. Please utilize the following code snippets
1. Lock a cell (A1) in the worksheet:
Workbook wb = new Workbook();
Worksheet sheet = wb.Worksheets[0];
Style style;
for(int i = 0; i <= 255; i ++)
{
style = sheet.Cells.Columns[(byte)i].Style;
style.IsLocked = false;
}
style = sheet.Cells["A1"].Style;
style.IsLocked = true;
Aspose.Cells.Protection protection = sheet.Protection;
wb.Save("d:\\lockedcell.xls", FileFormatType.ExcelXP);
2. Lock a complete row (First Row) in the worksheet:
Workbook wb = new Workbook();
Worksheet sheet = wb.Worksheets[0];
Style style;
StyleFlag flag;
for(int i = 0; i <= 255; i ++)
{
style = sheet.Cells.Columns[(byte)i].Style;
style.IsLocked = false;
flag = new StyleFlag();
flag.Locked = true;
sheet.Cells.Columns[(byte)i].ApplyStyle(style, flag);
}
style = sheet.Cells.Rows[0].Style;
style.IsLocked = true;
flag = new StyleFlag();
flag.Locked = true;
sheet.Cells.Rows[0].ApplyStyle(style, flag);
Aspose.Cells.Protection protection = sheet.Protection;
wb.Save("d:\\lockedcells.xls", FileFormatType.ExcelXP);
Regards
Amjad Sahi
Aspose Nanjing Team