How to remove tables and paragraphs containing data from docx in java using apache poi
I have a word template that has multiple similar tables and some paragraphs associated to those tables placed just before them. Depending on the amount of data, I populate some tables and others are not required, so are there paragraphs. I need to remove these tables and paragraphs. As you can see in the image, I need to remove Table 2 and its paragraph Table Parahgraph Please help me how to do it. I tried using document.removeBodyElement(pos) , but it does not help. int startIndex = 0; int endIndex = 0; startIndex = doc.getPosOfTable(doc.getTables().get(0)); startIndex++; endIndex = doc