Re: All my POI built Excel files are suddenly corrupt?

PJ Fanning <[email protected]> Fri, 11 Oct 2024 00:06:32 +0000 (UTC)
Newsgroups gmane.comp.jakarta.poi.user
Message-ID <[email protected]>
It would be useful to work out if Apache POI SXSSFWorkbook should default t=
o=C2=A0https://commons.apache.org/proper/commons-compress/apidocs/org/apach=
e/commons/compress/archivers/zip/Zip64Mode.html#AlwaysWithCompatibility

It would probably make sense to contact LibreOffice before contacting Commo=
ns-Compress. The latter would likely only be interested if there was a bug =
in their implementation.





On Friday 11 October 2024 at 00:13:37 IST, Andreas Reichel <andreas@mantico=
re-projects.com> wrote:=20





On Thu, 2024-10-10 at 23:03 +0000, PJ Fanning wrote:
> workBook.setZip64Mode(Zip64Mode.Never);
>
> Some tools may not be able to handle Zip64 mode.

You are my hero! The following works and no corruption.
Please don't allow/set Zip64Mode.Never, it will hang forever and is
hard to kill.

Now, who is to blame and where to report this problem to? Is is Commons
Compress or LibreOffice?

Thank you so much for the hint and help!

public class Main {
=C2=A0 =C2=A0 public static void main(String[] args) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 // this will cause corruption
=C2=A0 =C2=A0 =C2=A0 =C2=A0 SXSSFWorkbook wb=C2=A0 =3D new SXSSFWorkbook(ne=
w XSSFWorkbook(), 100, true, true);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 SXSSFSheet sheet =3D wb.createSheet("test");
=C2=A0 =C2=A0 =C2=A0 =C2=A0 wb.setZip64Mode(Zip64Mode.AlwaysWithCompatibili=
ty);


=C2=A0 =C2=A0 =C2=A0 =C2=A0 File outputFile =3D null;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 try {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 outputFile =3D File.createTempFil=
e("poitest_", ".xlsx");
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 FileOutputStream fileOutputStream=
 =3D new FileOutputStream(outputFile);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 wb.write(fileOutputStream);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 wb.close();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 } catch (IOException e) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 throw new RuntimeException(e);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 }
}