table.mergeCells: can't merge exception

good day,

i have read the online explanation of merging cells for slides but the api seems to work little differently.... :-(

i have created an arbitrary nxn table with existing merged cells as a template. i then load the slide and try to progmatically merge existing cells.

here are the things that i am running into:

1)merging cells the following way throws "can't merge exception":

"table.mergeCells(table.getCell(0,2),table.getCell(1,2));

table.mergeCells(table.getCell(0,2),table.getCell(2,2));"

the first two cells (x=0 and x=1) merges fine but the second pair throws an exception. but if i do:

"table.mergeCells(table.getCell(0,2),table.getCell(1,2));

table.mergeCells(table.getCell(0,2),table.getCell(1,2));"

it merges fine. but this is not consistant with the online document on how cells are renumbered.

2) next, row has 44 columns. i need to merge the first 10 cells together but after the 7th column merge it throws a "can't merge" exception. it also throws exception at other ith columns.

has anyone seen this problem/behavior? any work arounds?

thanks

joon

Dear joon,

Thank you for considering Aspose.Slides

You can merge only those cells which will form a rectangluar shape after merging. Further, the merged cell can be retrieved using the row and column id of any of the two cells that are merged.

During the merging process, you must give two cells which are adjacent to each other either row-wise or column-wise but not both.

For example see this example.

---------------------------------------------------------------------------

| Cell-1 (0,0) | Cell-2 (1,0) | Cell-3 (2,0) | Cell-4 (3,0) |

---------------------------------------------------------------------------

| Cell-5 (0,1) | Cell-6 (1,1) | Cell-3 (2,1) | Cell-4 (3,1) |

---------------------------------------------------------------------------

In the above you can see four cells in a single row. You can merge only adjacent cells that form rectangluar shape. For example, you can merge Cell-1 with Cell-5 or Cell-2

Suppose, in the above example, we merge Cell-2 and Cell-3

Then our table will look like this

---------------------------------------------------------------------------

| Cell-1 (0,0) | Cell-2 (1,0) Cell-3 (2,0) | Cell-4 (3,0) |

---------------------------------------------------------------------------

| Cell-5 (0,1) | Cell-6 (1,1) | Cell-3 (2,1) | Cell-4 (3,1) |

---------------------------------------------------------------------------

You can retrieved the merged cell either by using (col, row)=(1,0) or (2,0)

Now suppose, we want to merge Cell-1 with the merged cell above. When we will do so, we will retrieve the merged cell using (col, row)=(1,0) because (2,0) is not adjacent to Cell-1

But, if we want to merge Cell-4 with the merged cell above, we will retrieve the merged cell using (col, row)=(2, 0), because (1,0) is not adjacent to Cell-4

Hopefully, my example will help you to be clarified about merging cells and how does it work.