Syncfusion.XlsIO.Base
Example 


MergedCells Property

Gets all the merged ranges in the worksheet. Read-only.
Syntax
'Declaration
 
ReadOnly Property MergedCells As IRange()
'Usage
 
Dim instance As IWorksheet
Dim value() As IRange
 
value = instance.MergedCells
IRange[] MergedCells {get;}
Example
The following code illustrates how to get the merged ranges.
using Syncfusion.XlsIO;
using System;
            
class Program
{
    static void Main()
    {
        using (ExcelEngine excelEngine = new ExcelEngine())
        {
            //Create worksheet
            IApplication application = excelEngine.Excel;
            application.DefaultVersion = ExcelVersion.Excel2013;
            IWorkbook workbook = application.Workbooks.Create(1);
            IWorksheet worksheet = workbook.Worksheets[0];
            
            //Merge cells
            worksheet["C2:D2"].Merge();
            worksheet["F3:G3"].Merge();
            
            //Get merged ranges
            IRange[] mergedRanges = worksheet.MergedCells;
            
            //Get merged range count
            Console.Write(mergedRanges.Length);
            
            //Save and dispose
            workbook.SaveAs("CellFormats.xlsx");
            workbook.Close();
            Console.ReadKey();
        }
    }
}
//Output will be
//2
AssemblyVersion

Syncfusion.XlsIO.Base: 16.4460.0.40

See Also