我正试图使excel中选定的单元格可编辑,其余单元格只读。
以下是我的代码,我试图将指定行的Locked属性设置为"False",并试图保护工作表
excl.WorkSheet(0).Range[0, myColumns.Count, rowCount + 2, myColumns.Count].Locked = false; // Unlock cells to not make them read-only by ProtectContents
excl.WorkSheet(0).ProtectContents = true; //Make all the locked cells read only
假设rowCount=5,我希望0-6之间的整行都是可编辑的,但工作簿中的其余字段是只读的。
但是,整个薄片最终都受到了保护,而不是只锁定的细胞。有人能帮我修复这个吗
我做到了,并且能够实现我想要的,但我也渴望知道任何其他方法来做到这一点
IRange rows = excl.WorkSheet(0).Cells[rowStart, myColumns.Count].EntireRow;
rows.Locked = false;
excl.WorkSheet(0).ProtectContents = true;