https://bz.apache.org/bugzilla/show_bug.cgi?id=59252
--- Comment #4 from Alex <[email protected]> --- Ok, I took a look over source code and found the problem. This is method write(OutputStream) in POIXMLDocument: public final void write(OutputStream stream) throws IOException { //force all children to commit their changes into the underlying OOXML Package Set<PackagePart> context = new HashSet<PackagePart>(); onSave(context); context.clear(); //save extended and custom properties getProperties().commit(); getPackage().save(stream); } Key is the properties commit, that it's not done on close() method, so package doesn't notice any change. To test this, I updated my code so instead doing this: File trash= File.createTempFile("basura", ".tmp"); FileOutputStream trahsOs= new FileOutputStream(trash); wbx.write(trahsOs); trahsOs.close(); trash.delete(); It's enough to call with null and catch the Exception: try { wbx.write(null); } catch (Exception e) {} Do you think it could be right to change close() from: public void close() throws IOException { if (pkg != null) { if (pkg.getPackageAccess() == PackageAccess.READ) { pkg.revert(); } else { pkg.close(); } pkg= null; } } to: public void close() throws IOException { if (pkg != null) { if (pkg.getPackageAccess() == PackageAccess.READ) { pkg.revert(); } else { // force all children to commit their changes into the underlying OOXML Package Set<PackagePart> context= new HashSet<PackagePart>(); onSave(context); context.clear(); // save extended and custom properties getProperties().commit(); pkg.close(); } pkg= null; } } That leaving the close() discussion for other moment. -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
