I just opened and saved a docx file like this: File infile = new File("test.docx"); XWPFDocument xdoc = null; FileInputStream fis = new FileInputStream(infile); xdoc = new XWPFDocument(OPCPackage.open(fis)); FileOutputStream outstr = new FileOutputStream(new File("bug.docx")); xdoc.write(outstr); outstr.close(); This document contained a table, which was set to borderless. After opening the exported bug.docx, i noticed, that the above code added a border to the table. I looked into the document.xml, which contained the following: test.docx <w:tbl> <w:tblPr> <w:tblStyle w:val="Basic"/> <w:tblpPr w:horzAnchor="page" w:leftFromText="142" w:rightFromText="142" w:tblpX="1702" w:tblpY="937" w:vertAnchor="page"/> <w:tblW w:type="auto" w:w="0"/> <w:tblLayout w:type="fixed"/> <w:tblLook w:firstColumn="1" w:firstRow="1" w:lastColumn="0" w:lastRow="0" w:noHBand="0" w:noVBand="1" w:val="04A0"/> </w:tblPr> <w:tblGrid> <w:gridCol w:w="6804"/> </w:tblGrid> ... </w:tbl> There were some standard values added: bug.docx <w:tbl> <w:tblPr> <w:tblStyle w:val="Basic"/> <w:tblpPr w:horzAnchor="page" w:leftFromText="142" w:rightFromText="142" w:tblpX="1702" w:tblpY="937" w:vertAnchor="page"/> <w:tblW w:type="auto" w:w="0"/> <w:tblLayout w:type="fixed"/> <w:tblLook w:firstColumn="1" w:firstRow="1" w:lastColumn="0" w:lastRow="0" w:noHBand="0" w:noVBand="1" w:val="04A0"/> </w:tblPr> <w:tblPr> <w:tblW w:type="auto" w:w="0"/> <w:tblBorders> <w:top w:val="single"/> <w:left w:val="single"/> <w:bottom w:val="single"/> <w:right w:val="single"/> <w:insideH w:val="single"/> <w:insideV w:val="single"/> </w:tblBorders> </w:tblPr> <w:tblGrid> <w:gridCol w:w="6804"/> </w:tblGrid> ... </w:tbl> This problem is caused by the createEmptyTable method inside the XWPFTable. I think this method shouldnt be called in this case.
Can you attach the original and the failing document? XWPFTable.createEmptyTable() is only called if there are no rows in the table, is this the case here?
We did not get the sample file for a long time and so cannot easily fix anything here, thus I am closing this for now, please reopen with more information if this is still a problem for you.