Document Solutions for Excel, Java Edition | Document Solutions
Features / Worksheet / Range Operations / Merge Cells
In This Topic
    Merge Cells
    In This Topic

    DsExcel Java enables users to execute the merge operation on several cells by combining them into a single cell using merge method of the IRange interface. When a cell range is merged, the data of top left cell stays in the final merged cell, and the data of other cells in the given range is lost.

    If all the cells within the given range are empty, the formatting of top left cell in the cell range is applied to the merged cell, by default.

    In order to merge the range of cells, refer to the following example code.

    Java
    Copy Code
    // Merge the cell range A1:C4 into one single cell
    worksheet.getRange("A1:C4").merge();

    In order to merge only the rows of the specified range of cell into one, refer to the following example code.

    Java
    Copy Code
    // Merge the cell range H5:J6 into a single merged cell in one row.
    worksheet.getRange("H5:J6").merge(true);
    See Also