Hi, well the absurdly simplified solution would be something like this:
SheetData sheetData = ...
int start = 5;
int count = 3;
foreach (var row in sheetData.Elements<Row>().Skip(start))
{
if (count-- > 0)
row.SetAttribute(new OpenXmlAttribute("outlineLevel", string.Empty, "1"));
else
break;
}
This results in grouping rows "6", "7" and "8", you may notice that you just need to add
outlineLevel
attribute with the level's value to the required rows.
But again I need to point out that this very very simplified solution with which I'm just showing you what your goal is.
You see you need to actually evaluate the
row.RowIndex
when doing the iteration. Also in case some rows, that you are targeting to be inside your group, are missing you need to add them and apply the
outlineLevel
attribute on them as well.
I hope this will get you started in the right direction, if you need more let me know.