How to: Merge Cells or Split Merged Cells
- 2 minutes to read
When you merge a cell range, the data (value, formula and format settings) of only the top left non-empty cell will appear in the resulting merged cell. The data contained in other cells of the original range will be lost.
If all cells within the original range are empty, the range’s top left cell format will be applied to the merged cell.
A complete sample project is available at https://github.com/DevExpress-Examples/winforms-spreadsheetcontrol-api-e4655
Split Merged Cells
Call the Worksheet.UnMergeCells method with the passed range that contains merged cells to be split. Note that the content and formatting that were set in cells before merging will be lost (with the exception of the top left cell).
Split All Merged Cells in a Worksheet
To get all merged cells in the specified cell range, use the Range.GetMergedRanges method.
The image below shows how cells are merged and split in a worksheet (the workbook is opened in SpreadsheetControl). Note that only the “B2” data (the top left non-empty cell) appears in the merged cell.