I have a web application (tomcat 8.5.4, java 1.7.0_72) that was previously generating valid xlsx excel files using Apache POI. I'm working on converting the application to manage the jar dependencies with maven and now the file being generated is considered corrupted (or otherwise invalid) by excel. I haven't changed the code that generates the file at all and the jars included are mostly the same other than some version changes and removing some jars that were unused and not in the maven dependency tree (removed jars listed below).
Does anyone know what I could be doing to cause POI to generate the files differently or why excel thinks that these changes make it invalid? I've searched a lot for errors with POI and corrupted excel files and it looked like there were several bugs in POI were it could corrupt existing files or break creating large files, but nothing that looked like it applied in this case. I saw several questions here that looked like they could be similar but didn't end up applying.
Differences
When I change the xlsx files created before and after to zip files and extract them then compare the directories with windiff the differences are (working -> corrupted).
[content_types].xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?> -> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"> -> <Types>
_rels.rels, _rels\workbook.xml.rels
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"> -> <Relationships>
docprops\core.xml
The time created is different
<?xml version="1.0" encoding="UTF-8" standalone="no"?> -> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
xl\styles.xml
the numFmtId is 1 lower
xl\worksheets\sheet1.xml, docprops\app.xml, xl\sharedstrings.xml, xl\workbook.xml
Identical
Jars
My company is using a local artifactory repository instead of pointing at the official maven repository, so it's been lots of fun loading all the dependencies in. My assumption is that this is caused by a jar I'm missing or using the wrong version, but I'm not actually generating any errors, just getting a bad file.
I'm including poi-3.1.11.jar, poi-ooxml-3.11.jar, and poi-ooxml-schemas-3.11.jar. Previously we had commons-codec 1.9 in tomcat/lib and commons-codec 1.3 in WEB-INF/lib. Under maven I've included 1.9, although I also tried going back to 1.3 and the file was still corrupted.
I tried upgrading to all of the poi versions to 3.1.14, but that didn't solve it. I tried going back to the exact poi[-ooxml-schemas]-3.11-20141221 jars that were working before but that didn't solve it. I tried switching the SXSSFWorkbook to a normal XSSFWorkbook but that didn't solve it.
Here is a list of jars that I removed when converting to maven, would any of these have any affect on apache poi?
ecj-4.5.1
el-impl-2.2
itext-2.0.8
jimi-1.0
js
opencsv-1.8
standard (1.1.2)