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

Free Support Forum - aspose.com

Table Cell with colspan attribute is not rendering correctly


Colspan attribute of table cell is not working correctly with setAllowAutoFit(false). I have given colspan = “2” to first cell. so second cell will be merge. but if have given "table-layout:fixed " property to table then it is not merging the second cell.
For .docx and .pdf it is not rendering correctly, but for .doc it is working perfectly.

	Document doc = new Document();
	DocumentBuilder builder = new DocumentBuilder(doc);
	Table table = builder.startTable();		
	ParagraphFormat paragraphFormat = builder.getParagraphFormat();
	builder.write("Text in merged cells.");

	// This cell is merged to the previous and should be empty.

	builder.write("Text in one cell.");

	builder.write("Text in another cell.");
	table.setAllowAutoFit(false);   // Added "table-layout:fixed" by Table.AllowAutofit

Please check the attached outout.png file.Output.PNG (5.8 KB)


Thanks for your inquiry. We have tested the scenario with Aspose.Words for Java 17.8 and unable to notice the reported issue. Please download and try latest version of Aspose.Words for Java, it will resolve the issue.TestTable_false.zip (5.2 KB)

Hi @tilal.ahmad
I have downloaded Aspose 17.8 and checked with it. But I am facing the same issue. Could you please check again? Please try with the attached code and check the pdf result.TestTableRowCell.zip (997 Bytes)


Thanks for your feedback. I have again tested your shared code using Aspose.Words for Java 17.8 with JRE 1.8.0_60, but unable to notice the reported issue. TestTable_false.pdf (18.5 KB)

We will appreciate it if you please share your environment details along with your output documents here as well.

@tilal.ahmad Here is the env details we used.

OS architecture: amd64
Java VM name: IBM J9 VM
Java version: 1.7.0
Max Memory:1024

@Prahalad Verify with IBM JRE 8 and Oracle JRE 8. I would be surprised to see if the output differs based on the JRE.

@Prahalad, @kumaraswamy.m

Thanks for your patience. We have further investigated the issue. Please use updatePageLayout() method before saving the document. It will resolve the issue.


Thanks @tilal.ahmad,
I checked with doc.updatePageLayout . it resolves the issue. Does doc.updatePageLayout() internally calls doc.updateFields() method?


Thanks for your feedback. It is good to know that you have managed to resolve the issue.

Furthermore in reference to updateFields() related query. Please note updatePageLayout() method does not call updateFields() method. It rebuilds the page layout of the document. Whereas updateFields() does not update fields that are related to the page layout algorithms (e.g. PAGE, PAGES, PAGEREF).

Is there any order to call updateFields and updatePageLayout API?
Similarly, is there order to call updateTableLayout API as well?


Thanks for your inquiry. There is no specific order to call these methods. However, if you face any issue in this regard then please let us know.