As you can see in the picture, ShiftLeaders row is merged, however, from the 4th to 7th row the values are dynamic(If there are more data more rows will be filled). Because of that, I can't be sure what row to assign on setters and merge those two rows. The current way is displaying the table correctly, the problem is with setters and operators rows which can't be merged. Any help is appreciated!
Shift Leaders is ok:
ws.Cells["A3:C3"].Value = "Shift Leaders";
ws.Cells["A3:C3"].Merge = true;
Setters row is not merging:
ws.Cells[largestLeaders 4, 2].Value = "Setters";
ws.Cells[largestLeaders 4, 2].Merge = true;
As well as Operators row:
ws.Cells[largestSetters 4 largestLeaders 2, 2].Value = "Operators";
ws.Cells[largestSetters 4 largestLeaders 2, 2].Merge = true;
CodePudding user response:
it looks like you are using single cell instead of cell range. try with range:
int n = largestLeaders 4;
string range = $"A{n}:C{n}";
ws.Cells[range].Value = "Setters";
ws.Cells[range].Merge = true;