IXlSheet.MergedCells Property
Provides access to the collection of merged cells in a worksheet.
Namespace: DevExpress.Export.Xl
Assembly: DevExpress.Printing.v24.2.Core.dll
NuGet Package: DevExpress.Printing.Core
#Declaration
IXlMergedCells MergedCells { get; }
#Property Value
Type | Description |
---|---|
IXl |
An IXl |
#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.
Note
A complete sample project is available at https://github.
// 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.