Cells.GroupRows

GroupRows(int, int, bool)

Groups rows.

public void GroupRows(int firstIndex, int lastIndex, bool isHidden)
ParameterTypeDescription
firstIndexInt32The first row index to be grouped.
lastIndexInt32The last row index to be grouped.
isHiddenBooleanSpecifies if the grouped rows are hidden.

Examples

using System;
using Aspose.Cells;

namespace AsposeCellsExamples
{
    public class CellsMethodGroupRowsWithInt32Int32BooleanDemo
    {
        public static void Run()
        {
            // Create a workbook
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];
            Cells cells = worksheet.Cells;

            // Populate some data
            for (int i = 0; i < 10; i++)
            {
                cells[i, 0].PutValue($"Group {i + 1}");
                for (int j = 1; j <= 5; j++)
                {
                    cells[i, j].PutValue($"Data {j}");
                }
            }

            // Group rows 1 to 5 (0-based index) and hide them
            cells.GroupRows(1, 5, true);

            // Set summary row below the group
            worksheet.Outline.SummaryRowBelow = false;

            // Save the workbook
            workbook.Save("GroupRowsDemo.xlsx");
        }
    }
}

See Also


GroupRows(int, int)

Groups rows.

public void GroupRows(int firstIndex, int lastIndex)
ParameterTypeDescription
firstIndexInt32The first row index to be grouped.
lastIndexInt32The last row index to be grouped.

Examples

using System;
using Aspose.Cells;

namespace AsposeCellsExamples
{
    public class CellsMethodGroupRowsWithInt32Int32Demo
    {
        public static void Run()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            
            // Access the first worksheet
            Worksheet worksheet = workbook.Worksheets[0];
            Cells cells = worksheet.Cells;

            // Populate some sample data
            for (int i = 0; i < 10; i++)
            {
                cells[i, 0].PutValue("Row " + (i + 1));
            }

            // Group rows 2 to 5 (zero-based index)
            cells.GroupRows(1, 4);

            // Save the workbook
            workbook.Save("GroupRowsExample.xlsx");
        }
    }
}

See Also