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

Free Support Forum - aspose.com

Nesting multiple tables

I am creating a Word document using DocumentBuilder. in Aspose.Words for Java ver 1.14.7.0.
The data source is an xml document which i am parsing with SAX parser. I am having trouble with some elements that we convert to a Word table (such as drafting.note) which then contain tabular data. After reading some posts here my understanding is the container table must be created first, ended, and then the nested tables inserted into the appropriate table cell.

Since we are parsing the xml linearly I have prepped the source xml by “unnesting” the nested tables so we can create them in DocumentBuilder in the right order (i.e.outer table, then nested tables). I have assigned unique id values to the nested tables and inserted a text paragraph in the outer table with the ids as a placement marker. See markers Ica763f106c0911e498db8b09b4f043e0 and Ica763f116c0911e498db8b09b4f043e0 in outer table.

Can you please give an example for how I could find the correct Paragraph Node in the outer table wit h the markers and move the nested tables to the correct placement? Or if there is a better approach please let me know.
thank you.

attached is my current output Word doc.


Hi Linda,

Thanks for your inquiry.

treuters:

I am creating a Word document using DocumentBuilder. in Aspose.Words for Java ver 1.14.7.0.
The data source is an xml document which i am parsing with SAX parser. I am having trouble with some elements that we convert to a Word table (such as drafting.note) which then contain tabular data. After reading some posts here my understanding is the container table must be created first, ended, and then the nested tables inserted into the appropriate table cell.

You can created the nested table without ending the container/outer table. Please check the last code example shared in following documentation link.
http://www.aspose.com/docs/display/wordsjava/Inserting+a+Table+using+DocumentBuilder
treuters:

Can you please give an example for how I could find the correct Paragraph Node in the outer table wit h the markers and move the nested tables to the correct placement? Or if there is a better approach please let me know.
thank you.

In your case, I suggest you please insert the contents (having ids) inside bookmark. In this way you can get the paragraph by using bookmark node. Please read about inserting bookmarks from here:
http://www.aspose.com/docs/display/wordsjava/Bookmarks+in+Aspose.Words

Please check the following code example for your kind reference.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

builder.startBookmark("MyBookmark");

builder.writeln("Text inside a bookmark.");

builder.endBookmark("MyBookmark");

Paragraph para = (Paragraph)doc.getRange().getBookmarks().get("MyBookmark").getBookmarkStart().getAncestor(NodeType.PARAGRAPH);


If you still face problem, please manually create your expected Word document using Microsoft Word and attach it here for our reference. We will investigate as to how you want your final Word output be generated like. We will then provide you more information on this along with code.

This was helpful. Thank you!

Hi Linda,

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.