worksheet.Protection.IsProtected = true; worksheet.ProtectedRanges.Add(“editable”,new ExcelAddress(2,1,RowCount1,3));
但我必须保护可编辑字段中的少量数据行
答案 0 :(得分:0)
尝试使用ExcelRange的Style.Locked属性
// Protect the worksheet
ws.Protection.IsProtected = true; // NOTE: This locks all cells by default
// Make all cells editable
ws.Cells.Style.Locked = false;
// Lock just the first row
ws.Row(1).Style.Locked = true;
// Lock a range of rows
ws.Cells["4:6"].Style.Locked = true;