[]
        
(Showing Draft Content)

Merge Cells

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.

// Merge the cell range A1:B4 into one single cell
worksheet.getRange("A1:B4").merge();

DsExcel worksheet displays range A1 through B4 as one merged cell after calling IRange.merge without the across option.


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

// Merge the cell range C1:D4 into a single merged cell in one row.
worksheet.getRange("C1:D4").merge(true);

DsExcel worksheet displays row-wise merged cells in range C1 through D4 after calling IRange.merge with the across option.

See Also

Get Range and Range Area

Insert and Delete Rows and Columns

Work with Used Range