I made a mark in a .docx file like ${table}
,and now I want insert a table with apache poi xwpf in this marked place.
In other words I want to replace this mark ${table}
with a table.
Here is my code
List<XWPFParagraph> parasList = document.getParagraphs();
for(XWPFParagraph paragraph:parasList){
String paraText=paragraph.getText();
if(paraText.equals("${table}")) {
System.out.println("find:"+paraText);
int pos=document.getPosOfParagraph(paragraph);
XWPFTable newT=document.createTable();
document.insertTable(pos,newT);
}
}
How ever, the table can be created, but it appeared at the bottom of the word document.
What should I do?
here is code