Bug 58850 - XWPFTable adds border while just opening and saving
Summary: XWPFTable adds border while just opening and saving
Status: RESOLVED LATER
Alias: None
Product: POI
Classification: Unclassified
Component: XWPF (show other bugs)
Version: unspecified
Hardware: PC Windows NT
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-13 11:02 UTC by luk-ry
Modified: 2019-03-10 20:21 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description luk-ry 2016-01-13 11:02:49 UTC
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.
Comment 1 Dominik Stadler 2016-03-29 19:25:51 UTC
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?
Comment 2 Dominik Stadler 2019-03-10 20:21:59 UTC
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.