Sorry to say this but you will need to download the source for the project and create a patch for XWPF yourself so that it handles the insertion of tables correctly. Remember that POI is not a commercial product and that everyone that works on it does so as a volunteer. Typically, people develop areas of the api as they need that specific functionality; it seems as though you have a pressing need to work with tables and so are the ideal person to enhance this part.
The problem may not be as simple as it seems. Yesterday, I played around with some test code and found that the createTable() methods do create a new table that is added to the bottom of the list of body elements. If a call to the setTable() method is made, this will move the position of the table in the body element list but seems to create a second entry; it appears to leave the original entry at the bottom of the list and then create a second entry in the correct position. Confusingly however, saving this document creates xml markup with just a single copy of the table, the one created at the bottom of the list of body elements and it seems to me that the write process it doing something a little strange. To confirm this, I created the new table directly myself and then set it into the document. This did result in a list of body elements that showed a single entry for the table and in the correct position. It still, however, resulted in the markup being created with the table at the end of the document. This is why I suspect that something is awry with the writing of the markup when the document is saved, no proof just a suspicion. I cannot investigate further myself - not clever enough to dig around in the source code of the api - but this is what I feel you will have to do. Find out how the list of body elements is processed when the document is saved and why the position of the table within it is being ignored when a new table - seemingly, existing tables read in from documents are handled properly but I have yet to fully confirm this - is created and I think you will have the answer. -- View this message in context: http://apache-poi.1045710.n5.nabble.com/Replacing-placeholder-to-a-Table-tp3392424p5712081.html Sent from the POI - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
