IXlSheet.MergedCells Property

Provides access to the collection of merged cells in a worksheet.

Namespace: DevExpress.Export.Xl

Assembly: DevExpress.Printing.v21.1.Core.dll

Declaration

IXlMergedCells MergedCells { get; }

Property Value

Type Description
IXlMergedCells

An IXlMergedCells object that stores all merged cells in a worksheet.

Remarks

To merge adjacent cells in a worksheet into a single cell, use the IXlMergedCells.Add method of the IXlMergedCells collection, accessible by using the MergedCells property.

// Merge cells contained in the range A1:E1.
sheet.MergedCells.Add(XlCellRange.FromLTRB(0, 0, 4, 0));

// Merge cells contained in the range A2:A5.
sheet.MergedCells.Add(XlCellRange.FromLTRB(0, 1, 0, 4));

// Merge cells contained in the range B2:E5.
sheet.MergedCells.Add(XlCellRange.FromLTRB(1, 1, 4, 4));

To split a merged cell, remove it from the IXlMergedCells collection by using the IXlMergedCells.Remove or IXlMergedCells.RemoveAt method.

For more details on how to merge and unmerge cells in a worksheet, refer to the How to: Merge Cells or Split Merged Cells example.

See Also