Hi,
I noticed some issues with the isHidden attribute when calling Cells.GroupRows with some nested groups. For example, I have the same set of data. I would expect worksheet1 and worksheet2 to be identical. However, worksheet1 is showing some strange behavior where Cells A3, A4, and A5 are visible even though the outer group should be hidden. Worksheet2 merely changed the order of the GroupRows calls, but Cells A3+A4+A5 are collapsed when they shouldn’t be. Worksheet3 is another edge case where the inner groups should be collapsed, but they aren’t because the Cells.GroupRows(1,8,false) came last. Worksheet4 demonstrates the correct behavior for worksheet3.
var workbook = new Workbook();
workbook.Worksheets.Add();
workbook.Worksheets.Add();
workbook.Worksheets.Add();
var worksheet1 = workbook.Worksheets[0];
var worksheet2 = workbook.Worksheets[1];
var worksheet3 = workbook.Worksheets[2];
var worksheet4 = workbook.Worksheets[3];
worksheet1.Outline.SummaryRowBelow = false;
worksheet2.Outline.SummaryRowBelow = false;
worksheet3.Outline.SummaryRowBelow = false;
worksheet4.Outline.SummaryRowBelow = false;
for (int i = 1; i <= 9; ++i)
{
worksheet1.Cells[$"A{i}"].PutValue($"Row{i}");
worksheet2.Cells[$"A{i}"].PutValue($"Row{i}");
worksheet3.Cells[$"A{i}"].PutValue($"Row{i}");
worksheet4.Cells[$"A{i}"].PutValue($"Row{i}");
}
//Cells A3, A4, A5 are visible and shouldn't be
//The document behaves the way I would expect after I toggle the group manually
worksheet1.Cells.GroupRows(1, 8, true);
worksheet1.Cells.GroupRows(6, 8, true);
worksheet1.Cells.GroupRows(2, 4, false);
//Order of the GroupRows calls seems to matter as well as this produces a different result
//Cells A3, A4, A5 should be visible but are hidden after uncollapsing the outer group manually in excel
worksheet2.Cells.GroupRows(6, 8, true);
worksheet2.Cells.GroupRows(2, 4, false);
worksheet2.Cells.GroupRows(1, 8, true);
//Another modification on the same values
//The inner groups should be collapsed, but aren't when I set the outer group to be visible
worksheet3.Cells.GroupRows(6, 8, true);
worksheet3.Cells.GroupRows(2, 4, true);
worksheet3.Cells.GroupRows(1, 8, false);
//Moving the outer row call first works
worksheet4.Cells.GroupRows(1, 8, false);
worksheet4.Cells.GroupRows(6, 8, true);
worksheet4.Cells.GroupRows(2, 4, true);
workbook.Save("RowGroupingOrderBug.xlsx");