[prev in list] [next in list] [prev in thread] [next in thread]
List: poi-user
Subject: XWPFTable insertNewTableRow trouble
From: massimo malvestio <massimo.malvestio () gmail ! com>
Date: 2015-11-20 11:44:12
Message-ID: CAFzq1jaqi1OOTUo2XQURnVYUOLhKTkCJ4Ge-pp2c3XE8-u=D1Q () mail ! gmail ! com
[Download RAW message or body]
Hi everybody!
I'm trying to manipulate a docx using apache poi, but I got a problem with
the library.
Versions of apache poi tested: 3.13, 3.7
Word: 2013
I need to add a variable number of rows into a table and I use
insertNewTableRow, here the snippet of code I wrote to test the
functionality
//template
InputStream templateStream =
getClass().getResourceAsStream("./templates/test.docx");
XWPFDocument template = new XWPFDocument(OPCPackage.open(templateStream));
XWPFTable table = template.getTables().get(0);
//0 header, 1 empty existing row
table.insertNewTableRow(2);
File destFile = File.createTempFile("docx_test", ".docx");
BufferedOutputStream outputStream = new BufferedOutputStream(new
FileOutputStream(destFile));
template.write(outputStream);
outputStream.flush();
outputStream.close();
The docx is correctly generated, but when I try to open it, Word claims
it's not possible, a problem with its content has been found.
If I click on details section, an unspecified error is shown, related to
document.xml.
If I use createRow() everything goes fine, but I cannot use it because I
can need to insert a row between two already existing.
I tried to use addNewRowBetween(), but I found is an empty method,
watching the source code.
I tried createRow() then inserting the returned object in the correct
position, but doing so rows are duplicated. (Yes, I tried to use
removeRow() giving the position of the last row but it didn't work)
I don't know if I can attach docx, anyway the structure of the document is
quite simple, a table with header and one row.
Thanks people in advance for the support
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic