When I check the worksheet afterwards, the columns are not locked at all. There are no other style manipulations on the cells/columns after this piece of code. Other style manipulations like
The same problem occurs when trying to manipulate rows.
for (int i=0;i <= titleRow;i++) { ws.Cells.Rows.Style.IsLocked = true; }
this doesn't work.
Although when I write an iteration to handle cell by cell then their is no problem. It seems that Style isn't set when applying it to a collection like ws.Cells.Rows or ws.Cells.Columns
Isn't that dangerous? I mean, wouldn't I lose other particular style settings if I set the Style using a new Style object because I think the default values for the other style properties will get applied.
You don't use a new style object. My sample code changes the style object and re-assign to row or column. When the style is changed, it internally changes style for each cells. Other style settings will not be lost.