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

Free Support Forum - aspose.com

Table cell merge issue

Hello there.
Aspose words is used in a a very critical feature in my company’s application where we generate contracts in ms word.

I am having an issue in performing cell horizontal merge inside a table.

Following is the pseudo code :-

1.Load the document
2.Get the table.
3.Horizontal merge
cell.getCellFormat().setHorizontalMerge(CellMerge.FIRST);
nextCell.getCellFormat().setHorizontalMerge(CellMerge.PREVIOUS);
4. Vertical merge:-
cell.getCellFormat().setVerticalMerge(CellMerge.FIRST);
nextCell.getCellFormat().setVerticalMerge(CellMerge.PREVIOUS);
5. end

But, after performing the merge only the contents from the FIRST cell are preserved and the rest of them are lost.

So I added the following code after each merge.

origCell.appendChild(nextCell.getFirstParagraph());

Now the contents of all the cell were preserved in horizontal and vertical merge.

But the issue is:-

In HORIZONTAL MERGE the above mentioned code puts the contents of the cell BELOW the ORIGINAL CELL.

I want the contents of horizontally merged cell to have the same alignment(The value should be below the header field ) as before the merging but in one cell.

I am attaching the document for you guys.

This is a very critical issue for my company and I need to fix it ASAP.

Please help.

Thanks and Regards
Vishal

Hi Vishal,


Thanks for your inquiry.

The behavior you have seen is expected as you are appending the paragraphs from the other cells onto the first. Each paragraph appears on a new line.

If you want to have each paragraph still lined up under its heading then it sounds like you shouldn’t be merging these cells at all. Instead you may be able to get the desired effect by simply removing the inner border lines in the target cells. Please see the link here for details: http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/aspose.words.tables.cellformat.borders.html

Thanks,

Thanks Adam for for quick diagnosis and reply. I really appreciate it.

The workaround you suggested I could sell it to the management and it was easy to implement.

Cheers!
Vishal