We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to set GroupLevel

Hello, I am trying to set the GroupLevel for certain rows and columns, but the properties Row.GroupLevel and Column.GroupLevel are read-only. How can I set these values directly?

I’m aware of the documentation page at
which says “Every time you group the rows, the outline number is increased by 1.” - Will this number be increased every time GroupRows() or GroupColumns() is called, even if these rows/columns are part of their own group already?

Thank you!

@DerrickAccountNumberTwo,
You may follow this link to set the GroupLevel for rows and columns.

Regarding the increment in outline number by grouping the rows multiple times, yes it will increase every time. Here is an example to demonstrate this behaviour where row index 1 is grouped multiple times hence its GroupLevel number increases by 1 after each operation.

Workbook workbook = new Workbook();
// Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];
Console.WriteLine(worksheet.Cells.Rows[1].GroupLevel);
// Grouping first six rows (from 0 to 5) and making them hidden by passing true
worksheet.Cells.GroupRows(0, 5, true);
// Grouping first three columns (from 0 to 2) and making them hidden by passing true
worksheet.Cells.GroupColumns(0, 2, true);
Console.WriteLine(worksheet.Cells.Rows[1].GroupLevel);
worksheet.Cells.GroupRows(1, 2, true);
Console.WriteLine(worksheet.Cells.Rows[1].GroupLevel);
// Saving the modified Excel file
workbook.Save(path + "output.xls");

If you still face some issue provide us your sample code, template file, program output and expected output generated by MS Excel. We will analyze this information and provide assistance accordingly.