Xceed Workbooks for .NET v2.0 Documentation
MergedCellCollection Class
Members  Example 


Xceed.Workbooks.NET Assembly > Xceed.Workbooks.NET Namespace : MergedCellCollection Class
Represents a collection of all the Cells that need to be merged.
Object Model
MergedCellCollection ClassCellRange Class
Syntax
'Declaration
 
<DefaultMemberAttribute("Item")>
Public Class MergedCellCollection 
   Inherits WorksheetElement
'Usage
 
Dim instance As MergedCellCollection
[DefaultMember("Item")]
public class MergedCellCollection : WorksheetElement 
Remarks
Note that the style of the merged Cells is determined by the information provided in the StartingElement (Style and text). All other informations will be hidden once the Cells are merged.
Example
using( var workbook = Workbook.Create( "MergedCellCollection.xlsx" ) ) 
  { 
    // Gets the first Worksheet; a Workbook always contains at least 1 Worksheet. 
    var worksheet = workbook.Worksheets[ 0 ]; 

    // Merges Cells A1 to B2. 
    var mergedCells = worksheet.MergedCells.Add( "A1", "B2" ); 
    var cellCount = mergedCells.Count; 

    // Merges the Cells in the D4 to D8 range. 
    var cellRange = worksheet.Cells[ "D4", "D8" ]; 
    cellRange.MergeCells(); 

    // Saves Workbook to disk; 
    workbook.Save(); 
  }
Inheritance Hierarchy

System.Object
   Xceed.Workbooks.NET.WorkbookElement
      Xceed.Workbooks.NET.WorksheetElement
         Xceed.Workbooks.NET.MergedCellCollection

Requirements

Target Platforms: Windows 11, Windows 10, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

MergedCellCollection Members
Xceed.Workbooks.NET Namespace