问题
I'm using closedxml to export excel..
Now i can protect (Lock cell) cell using the following function,
workSheet.Cell(rowIndex,column).Style.Protection.SetLocked(true);
I want to set group of cells.. Is that Possible in closedxml ?
回答1:
You can use Range
like so
workSheet.Range(startRow, startColumn, endRow, endColumn).Style.Protection.SetLocked(true);
回答2:
@Raidri, thanks for the answer that you provided here, but I want to add my own answer.
I found that when you want to lock a cell, the Worksheet must first be protected, or else the lock does nothing.
The worksheet can be protected with workSheet.Protect()
method. However, this will have all the cells locked by default, so you'll actually want to protect the worksheet and then unlock the cells you want to be editable.
来源:https://stackoverflow.com/questions/20286191/set-lock-true-for-group-of-cells