Document Solutions for Excel, .NET Edition | Document Solutions
Features / Group / Create Row or Column Group
In This Topic
    Create Row or Column Group
    In This Topic

    You can apply grouping on rows and columns of a spreadsheet.

    Apply row grouping

    You can apply row grouping by using the Group method of the IRange interface and specifying the rows you want to apply grouping on.

    Refer to the following example code to apply row grouping in a worksheet.

    C#
    Copy Code
    //1:20 rows' outline level will be 2.
    worksheet.Range["1:20"].Group();

    Apply column grouping

    You can apply column grouping by using the Group method of the IRange interface and specifying the columns you want to apply grouping on.

    Refer to the following example code to apply column grouping in a worksheet.

    C#
    Copy Code
    //A:I columns' outline level will be 2.
    worksheet.Range["A:I"].Group();

    Set outline level for rows and columns

    When the data is grouped for the first time, it displays only the rows arranged into the first level group on the basis of the values of the cells in that particular column. After the first-level grouping, when the view is grouped by any column other than the one used previously, the rows will be arranged in the second level group, third level group and so on.

    In case you want to set the specific outline level for grouping of rows or columns, you can use the OutlineLevel property of the IRange interface.  You can also choose to display specified levels of row or column groups using the ShowLevels method of the IOutline interface.

    Refer to the following example code to set the Outline level for rows and columns.

    C#
    Copy Code
    //1:10 rows' outline level will be 4.
    worksheet.Range["1:10"].Group();
    worksheet.Range["1:10"].OutlineLevel = 4;
    
    //A:E columns' outline level will be 4.
    worksheet.Range["A:E"].Group();
    worksheet.Range["A:E"].OutlineLevel = 4;
    

    You can use SummaryColumn property or SummaryRow property of the IOutline interface to set whether summary column is in left or right of column groups or summary row is above or below the row groups, respectively.