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

    DsExcel allow you to merge several cells into a single cell using Merge method of IRange. 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.

    Also if all the cells within the given range are empty, the formatting of range's top left cell is applied to the merged cell.

    Refer to the following example code to merge the range of cells.

    C#
    Copy Code
    // merge the cell range A1:B4 into one single cell
    worksheet.Range["A1:B4"].Merge();

    Refer to the following example code to merge only the rows of the specified range of cell into one.

    C#
    Copy Code
    // merge the cell range C1:D4 by one single cell in one row
    worksheet.Range["C1:D4"].Merge(true);
    See Also