groupRows method
Groups rows fromRow-toRow (0-based, inclusive) into a collapsible
outline. Each call nests one level deeper (Excel's "Group", max 7). When
collapsed is true the rows are hidden and the summary row just below the
group is flagged collapsed (Excel's default "summary below" layout).
sheet.groupRows(1, 4); // collapsible detail rows 2-5
sheet.groupRows(1, 4, collapsed: true); // ...starting collapsed
Implementation
void groupRows(int fromRow, int toRow, {bool collapsed = false}) {
if (fromRow < 0 || toRow < fromRow) return;
for (var r = fromRow; r <= toRow; r++) {
final next = (_rowOutlineLevel[r] ?? 0) + 1;
_rowOutlineLevel[r] = next > 7 ? 7 : next;
if (collapsed) _rowHidden.add(r);
}
if (collapsed) _rowCollapsed.add(toRow + 1);
}