I am using the aspose.word for java to create the doc as I need, I can created a nested table in the noe doc and the inner table can be displayed correctly in MS Word but not in the OpenOffice.
always show the first row of inner table correctly but the rest rows and cells messed up. Is there any method to make the inner table looks correct in OpenOffice? I attached a new generated doc, hope you can provide some sample code and solution to handle this issue. this is code I am using to generate the new doc:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
//Start table
Table t0 = builder.startTable();
//Specify borders formating
builder.getCellFormat().getBorders().setLineStyle(LineStyle.SINGLE);
builder.getCellFormat().getBorders().setColor(Color.black);
builder.getCellFormat().setWidth(200);
//Insert one cell into the table
builder.insertCell();
builder.writeln(“outer table cell 1”);
builder.insertCell();
builder.writeln(“outer table cell 2”);
builder.endRow();
builder.insertCell();
builder.writeln(“outer table cell 3”);
builder.insertCell();
builder.writeln(“outer table cell 4”);
builder.endRow();
builder.endTable();
builder.getCellFormat().clearFormatting();
//Now we can build nested table.
t0.getFirstRow().getFirstCell().ensureMinimum();
//Move DocumentBuilder cursor into the table
builder.moveTo(t0.getFirstRow().getFirstCell().getParagraphs().get(0));
builder.getCellFormat().getBorders().setLineStyle(LineStyle.SINGLE);
builder.getCellFormat().getBorders().setColor(Color.blue);
builder.insertCell();
builder.getCellFormat().setWidth(40);
builder.writeln(“1,1”);
builder.insertCell();
builder.getCellFormat().setWidth(40);
builder.writeln(“1,2”);
builder.insertCell();
builder.getCellFormat().setWidth(40);
builder.writeln(“1,3”);
builder.endRow();
builder.insertCell();
builder.getCellFormat().setWidth(40);
builder.writeln(“2,1”);
builder.insertCell();
builder.getCellFormat().setWidth(40);
builder.writeln(“2,2”);
builder.insertCell();
builder.getCellFormat().setWidth(40);
builder.writeln(“2,3”);
builder.endRow();
builder.endTable();
doc.save("/Volumes/Learnosity/workspaces/javatest/newtable.doc");
thank you
Hi Matthew,
Thanks for your inquiry.
I managed to reproduce the issue on my side. However this is not a bug with Aspose.Words, but rather a limitation of nested table interoperability between Microsoft Word and Open Office Writer.
If you create a nested table within Microsoft Word and then try to open it using Open Office Writer you will find the same sort of issue. Also if you do the opposite and create a nested table in OpenOffice Writer and try to open it in Microsoft Word a similar issue occurs.
From this you can see that Open Office Writer has a problem understanding nested tables in .DOC format and MS Word cannot properly understand nested tables in .ODT format either.
I'm afraid because of the points above there is nothing to fix.
Thanks,
Thanks for your quick reply.
Given by your explanation above, the aspose.words for java library is designed for MS Office word doc but not suitable for working with OpenOffice doc, right?
Hi Matthew,
Thanks for this additional information. Aspose.Words can work fully with both formats. If you save your document in the .odt format (the native Open Office Writer format) then this issue does not occur.
This issue is only caused because MS Word and Open Office Writer cannot properly understand nested tables in each others format.
Thanks,