Document Solutions for Excel, Java Edition | Document Solutions
Features / Group / Remove a Group
In This Topic
    Remove a Group
    In This Topic

    You can remove a group in DsExcel Java by referring to the following tasks in your worksheet.

    Ungroup rows and columns

    You can ungroup the grouped rows or columns if you no longer want the information to be organized. Also, you can increment or decrement the outline level for the specified rows or columns using the group method and ungroup method of the IRange interface respectively.

    In order to ungroup row and column in a worksheet, refer to the following example code.

    Java
    Copy Code
    // Row ungrouping
    // 1:20 rows' outline level will be 2.
    worksheet.getRange("1:20").group();
    // 1:10 rows' outline level will be 3.
    worksheet.getRange("1:10").group(); 
    // 1:5 rows' outline level will be 2.
    worksheet.getRange("1:5").ungroup();
    // 1:5 rows' outline level will be 1.
    worksheet.getRange("1:5").ungroup();
            
    // Column ungrouping
    // A:I columns grouping.
    worksheet.getRange("A:I").group();
    // A:I columns ungrouping 
    worksheet.getRange("A:I").ungroup();

    Clear outline

    You can clear the outline level of the specified rows or columns using the clearOutline method of the IRange interface.

    In order to clear outline in a worksheet, refer to the following example code.

    Java
    Copy Code
    // 1:20 rows' outline level will be 2.
    worksheet.getRange("1:20").group();
    // 1:10 rows' outline level will be 3.
    worksheet.getRange("1:10").group();
            
    // Clear outline
    // 12:20 rows' outline level will be 1.
    worksheet.getRange("12:20").clearOutline();

    Collapse a group

    You can collapse a group by using the setShowDetail method of the IRange interface and setting it to boolean false.

    In order to collapse a group in a worksheet, refer to the following example code.

    Java
    Copy Code
    // 1:20 rows' outline level will be 2.
    worksheet.getRange("1:20").group();
    // 1:10 rows' outline level will be 3.
    worksheet.getRange("1:10").group();
            
    // Collapse the group
    // 1:10 rows will be collapsed.
    worksheet.getRange("11:11").setShowDetail(false);