mardi 31 mars 2015

Empty box created when inserting a table using XMLCursor to XWPFDocument


Vote count:

0




When I inset a table into a XWPFDocument using an XMLCursor it is inserting the table into the correct position but it is adding an extra box under the first column. The box is joined onto the table so it looks like it is an additional table cell but when I insert the table without using and XMLCursor the table is correct and the box is at the position of the XMLCursor. Is there any way to delete the box as it looks like its an additional table cell.



XWPFDocument part1Document = new XWPFDocument(part1Package);
XmlCursor xmlCursor = part1Document.getDocument().getBody().getPArray(26).newCursor();

//create first row
XWPFTable tableOne = part1Document.createTable();

XWPFTableRow tableOneRowOne = tableOne.getRow(0);
tableOneRowOne.getCell(0).setText("Hello");
tableOneRowOne.addNewTableCell().setText("World");

XWPFTableRow tableOneRowTwo = tableOne.createRow();
tableOneRowTwo.getCell(0).setText("This is");
tableOneRowTwo.getCell(1).setText("a table");

tableOne.getRow(1).getCell(0).setText("only text");


XmlCursor c2 = tableOne.getCTTbl().newCursor();

c2.moveXml(xmlCursor);

c2.dispose();
XWPFTable tables = part1Document.insertNewTbl(xmlCursor);
xmlCursor.dispose();


The empty box is appearing at the position of the 26th paragraph. Any help would be great. Thanks.



asked 2 mins ago







Empty box created when inserting a table using XMLCursor to XWPFDocument

Aucun commentaire:

Enregistrer un commentaire