poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Millies, Sebastian" <sebastian.mill...@ids-scheer.com>
Subject Writing XSSFWorkbook as a nested ZipEntry into a ZipOutputStream
Date Thu, 28 Feb 2013 22:14:56 GMT
Hello there,

in my application, I pass around a ZipOutputStream and several objects write themselves into

I intend for an XSSFWorkbook to do the same, i. e. I want the xlsx-file to be just one more

However, XSSFWorkbook.write(OutputStream) will ultimately call the relevant code in ZipPackage.saveImpl(OutputStream),

which, when given a ZipOutputStream will simply “flatten out” the structure and write
the parts of the xlsx-file directly into

the stream, without the required nesting.

The only workaround that I can think of is to create my own “NestedZipPackage” with a
saveImpl() method more suited to

my requirement and pass that to the constructor of my XSSFWorkbook.

Any better ideas?

n  Sebastian

PS: In view of the fact, that XSSFWorkbook.write(OutputStream) closes the stream, I’ll have
to do something about it anyway,

because I may need to keep my ZipOutputStream open for adding further ZipEntries. But that’s
another problem. However,

in my opinion closing the stream inside the write method is a bad decision (HSSFWorkbook didn’t,
which made life easier).

IDS Scheer Consulting GmbH
Geschäftsführer/Managing Directors: Michael Rehm, Ivo Totev
Sitz/Registered office: Altenkesseler Straße 17, 66115 Saarbrücken, Germany - Registergericht/Commercial
register: Saarbrücken HRB 19681

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message