If I insert an html table or multiple tables after moving to a bookmark, how would I get the table so that I could apply an additional style or formatting to it? Is there any way to get to the table by a particular id or style so that I know I’m formatting the proper table if there are multiples?
Hi
Thanks for your request. You can get any of table using an index of a table collection:
// Get collection of tables
NodeCollection tables = doc.getChildNodes(NodeType.TABLE, true);
// Get table by table index
Table myTable = (Table) tables.get(1);
Also you can try putting some bookmark inside the table and then get this table using the following code:
// Open document.
Document doc = new Document("in.doc");
DocumentBuilder builder = new DocumentBuilder(doc);
// Move DocumentBuilder cursor to the bookmark.
builder.moveToBookmark("myBk");
// Get Table, where bookmark is located.
Table myTable = (Table) builder.getCurrentParagraph().getAncestor(NodeType.TABLE);
Hi there,
Thanks for your inquiry.
Please try using the method in the code below instead. This will return an List of nodes inserted during the InsertHtml call.