Reading Excel file throws Zip-error (Java version 21.10 and older)

Reading in an Excel file throws this exception:

Error for ZipFile
Nested Exception is:
com.aspose.cells.CellsException
com.aspose.cells.CellsException: Error for ZipFile
at com.aspose.cells.zbbl.a(Unknown Source)
at com.aspose.cells.a.f.zj.(Unknown Source)
at com.aspose.cells.a.f.zj.a(Unknown Source)
at com.aspose.cells.zsa.a(Unknown Source)
at com.aspose.cells.zjq.a(Unknown Source)
at com.aspose.cells.zjq.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.(Unknown Source)

Reading the file by a simple Java-Zip-Test program does work, as well as using Excel

Please find attached file for testing.excel.zip (265.7 KB)

Regards,

Steffen

@steffen.brehme.lobst,
I can not reproduce the issue while loading file with Workbook constructor. Please share your sample code with us for our testing.

@steffen.brehme.lobst,

Please try our latest version/fix (attached): Aspose.Cells v21.10.3:
aspose-cells-21.10.3-java.zip (7.4 MB)

I have tested using latest version and it works fine.

Hi Amjad_Sahi,

using the constructur with filename as string, it works. Using stream construcutor (with attached file), you should get the same exception as I do:

InputStream input = new BufferedInputStream(new FileInputStream("/home/develop/tmp/excel.xlsx"));
wb = new Workbook(input);

java.util.zip.ZipException: invalid entry size (expected 0 but got 1052 bytes)
at java.util.zip.ZipInputStream.readEnd(ZipInputStream.java:384)
at java.util.zip.ZipInputStream.read(ZipInputStream.java:196)
at java.util.zip.ZipInputStream.skip(ZipInputStream.java:249)
at com.aspose.cells.a.d.zi.a(Unknown Source)
at com.aspose.cells.a.d.zi.(Unknown Source)
at com.aspose.cells.a.d.zg.a(Unknown Source)
at com.aspose.cells.a.d.zl.(Unknown Source)
at com.aspose.cells.a.d.zl.a(Unknown Source)
at com.aspose.cells.ztf.a(Unknown Source)
at com.aspose.cells.zkk.a(Unknown Source)
at com.aspose.cells.zkk.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.(Unknown Source)

Used your latest attached lib, constructor with filename is not an option…

Regards,

Steffen

@steffen.brehme.lobst,

You are right, using stream constructor (with your attached file), we get the same exception as you found. I have logged a ticket with an id “CELLSJAVA-43959” for your issue. We will look into it soon.

Once we have an update, we will let you know.

1 Like

@steffen.brehme.lobst,

We evaluated your issue further and found it is not an issue with the APIs.
Even without references to our component, we can still get the same exception when reading data with Java’s Zip APIs from the InputStream based on your template file.

For such kind of file, because Java’s zip APIs cannot handle it well, so you should use file path directly instead of InputStream. If you have to use InputStream, we also provide one option Aspose.Cells.ZipTool to handle it. you may specify it by JVM option:
-DAspose.Cells.ZipTool=TEMPFILE

With this option we will use temp file to cache the data loading from the InputStream.

Well, we did extract the same xlsx file by using plain java.io.zip classes without any error(s). Therefore I still believe it is a bug in the internal stream handling of Aspose. Writing into a a temp. file will be a solution until the bug is fixed but is not acceptable for a productive system for a long time. I hope you agree.

Regards,

Steffen

Could you please share sample code and details on it? We will check it further.

… sorry for the last post. Had used the wrong input file - you are right, we are getting the same exception. Therefore this is an issue of the java implementation… You can close the ticket, thanks for the support!

@steffen.brehme.lobst,

Thanks for the clarification. We have closed this thread.