We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Unmerge cells


I tried to use the method Cells.UnMerge to unmerge the cells. However this method requires the number of rows input for a merged cell. I have a excel sheet where a column - "Code" had all the merged cells. My problem is, each merged cells have different number of rows :-( How do i loop thru the merged cells and UnMerge them?

I've attached the excel file.



Hi Dawn,

Thanks for considering Aspose.

I think you may try to use Cells.MergedCells property which returns the array list collection and each array list basically denotes a cell area.May the following code helps you for your need (The code below unmerges the code column cells only):

Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
Cells cells = worksheet.Cells;
ArrayList al = new ArrayList();
al = cells.MergedCells;
CellArea ca;
int frow,fcol,erow,ecol,trows,tcols;
for (int i = 0;i< al.Count;i++)
ca = new CellArea();
ca = (CellArea)al[i];
frow = ca.StartRow;
fcol = ca.StartColumn;
erow = ca.EndRow;
ecol = ca.EndColumn;
//Unmerge only "code" column cells.
trows = erow -frow +1;
tcols = ecol - fcol +1;




Thank you.

Thank you very much :slight_smile: it’s working!