Bug 62632 - Cannot remove BodyElements from XWPFTableCell
Summary: Cannot remove BodyElements from XWPFTableCell
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XWPF (show other bugs)
Version: 3.17-FINAL
Hardware: PC Mac OS X 10.1
: P2 normal with 1 vote (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-17 08:53 UTC by martijn.raats
Modified: 2021-05-20 11:10 UTC (History)
2 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description martijn.raats 2018-08-17 08:53:41 UTC
I would like to remove all content from a XWPFTableCell. But there seems to be no way of doing this.

I can remove paragraphs from a XWPFTableCell, by using the removeParagraph(int pos) method, but then I am left with 2 problems:

* the removeParagraph(int pos) method does not change the "bodyElements" member, which gives problems when later getBodyElements() is called, since the removed paragraph is still in the list
* I am unable to remove other content from the XWPFTableCell, like for example a XWPFTable

As workaround I currently set all the runs of all the paragraphs to the text "" and I remove all the TableRows of every XWPFTable that is in the cell. The problem with this workaround is that I end up with a lot of "enters" in the document.
Comment 1 Sayi 2021-05-20 11:10:25 UTC
The problem seems to have been resolved in the latest poi version.

1. removeParagraph will change bodyElements
2. You can remove the table in the cell through removeTable