Free Support Forum - aspose.com

Start and End column of Merged cell

I have few merged cells in excel workbook. I want to know the start and end column of exach merged cells. please see attachment.

EXAMPLE:
For MERGED CELL2 I need Column Start = “C” and Column End = "L"

Regards,
Raj

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

Please find your merged cell from the Worksheet.Cells.MergedCells. It is a list of all merged cells inside your worksheet. After that convert your merged cell into cell area object.

From cell area object, you can find the start and end column of your merged cells.

C#


string filePath = @“F:\Shak-Data-RW\Downloads\source.xlsx”;

Workbook workbook = new Workbook(filePath);


Worksheet worksheet = workbook.Worksheets[0];


CellArea area = (CellArea)worksheet.Cells.MergedCells[0];


int startColumn = area.StartColumn;

int endColumn = area.EndColumn;