Resulting styles.xml doesn't match the one in the .jar
Posted: Sun Jul 03, 2016 4:33 am
My program works fine in eclipse: it generates the document with the desired font, and visible table borders (which are for some reason hidden by default).
However once exporting to .jar I've had consecutive problems, which I resolved until this one.
First, the resulting .jar didn't have a styles.xml, so it generated the document with the default font, etc. Fix was to manually add the styles.xml into the jar.
Next, the parser failed on the header. In the line
Finally, it generated the doc without throwing any exception. However, when opening the doc, Word refuses to open it, saying it is corrupted. Upon looking I discovered that, for some reason, the styles.xml included in the doc had an empty rFonts attribute.
So basically, the styles.xml in the jar is:
and the resulting styles.xml is:
Notice the empty w:rFonts attribute that, I assume, triggers an exception in Word's parsing.
Why does it remove that attribute?
Also I'd like to thank you jason for the work you're providing
However once exporting to .jar I've had consecutive problems, which I resolved until this one.
First, the resulting .jar didn't have a styles.xml, so it generated the document with the default font, etc. Fix was to manually add the styles.xml into the jar.
Next, the parser failed on the header. In the line
- Code: Select all
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
Finally, it generated the doc without throwing any exception. However, when opening the doc, Word refuses to open it, saying it is corrupted. Upon looking I discovered that, for some reason, the styles.xml included in the doc had an empty rFonts attribute.
So basically, the styles.xml in the jar is:
- Code: Select all
<w:styles xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:docDefaults>
<w:rPrDefault>
<w:rPr>
<w:rFonts w:asciiTheme="Times New Roman" w:eastAsiaTheme="Times New Roman" w:hAnsiTheme="Times New Roman" w:cstheme="Times New Roman" />
<w:sz w:val="24" />
<w:szCs w:val="24" />
<w:lang w:val="en-US" w:eastAsia="en-US" w:bidi="ar-SA" />
</w:rPr>
</w:rPrDefault>
<w:pPrDefault>
<w:pPr>
<w:spacing w:line="240" w:lineRule="auto" />
</w:pPr>
</w:pPrDefault>
</w:docDefaults>
...
and the resulting styles.xml is:
- Code: Select all
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:styles xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" ... xmlns:ns32="http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas">
<w:docDefaults>
<w:rPrDefault>
<w:rPr>
<w:rFonts/>
<w:sz w:val="24"/>
<w:szCs w:val="24"/>
<w:lang w:val="en-US" w:eastAsia="en-US" w:bidi="ar-SA"/>
</w:rPr>
</w:rPrDefault>
<w:pPrDefault>
<w:pPr>
<w:spacing w:line="240" w:lineRule="auto"/>
</w:pPr>
</w:pPrDefault>
</w:docDefaults>
...
Notice the empty w:rFonts attribute that, I assume, triggers an exception in Word's parsing.
Why does it remove that attribute?
Also I'd like to thank you jason for the work you're providing