Error for zip file (#1096)

Hi,

When I try to open excel file P034_EN_0008_Bill of Materials_GMSS 3 Phase_Prototype.zip (124.6 KB)
, I receive an error (Error for zip file). Can you help me with this?

Workbook workbook = new Workbook(“P034_EN_0008_Bill of Materials_GMSS 3 Phase_Prototype.xlsx”);
workbook.save(“P034_EN_0008_Bill of Materials_GMSS 3 Phase_Prototype.xlsx”);

I’m using Aspose.Cells 16.11.0 for Java.

Regards,
Zeljko

@Zeljko

Thanks for using Aspose APIs.

We were able to observe this issue as per your description and logged it in our database for investigation and for a fix. Once, the issue is resolved or we have some other news for you, we will let you know asap.

This issue has been logged as

  • CELLSJAVA-42382 - Error for zip file - occurs on loading Excel file

@Zeljko,

We have evaluated your issue thoroughly. Well, your provided file cannot be read by Java’s zip relevant APIs, below code will give the same Exception:
e.g
Sample code:

ZipInputStream zis = new ZipInputStream(new FileInputStream("P034_EN_0008_Bill of Materials_GMSS 3 Phase_Prototype.xlsx"));
while(true)
{
    ZipEntry ze = zis.getNextEntry();
    if(ze == null)break;
    System.out.println(ze.getName());
}

For such kind of file, we provide one System property which allows user to use Apache’s Zip tool to replace JDK’s default zip apis:
e.g
Sample code:

System.setProperty("Aspose.Cells.ZipTool", "APACHE");
Workbook wb = new Workbook("P034_EN_0008_Bill of Materials_GMSS 3 Phase_Prototype.xlsx");

To use apache’s zip tool, please add corresponding library (for example, ant.jar) into the classpath before executing the application.

Thank you.

Hi,

Thanks for your answer.

Can you please tell me how can I check if excel file cannot be read by Java’s zip relevant API (like in this case), and it is needed to use Apache’s Zip tool?

Regards,
Zeljko

@Zeljko,

I think you may add the line at the start on a safer side as it will use Apache’ zip tool as needed. Alternatively, you may catch the exception and then use the suggested line(s) to cope with it.

I have also logged your concerns against your issue “CELLSJAVA-42382” into our database. Our concerned developer from product team will evaluate and we will get back to you soon.

Thank you.

@Zeljko

We are afraid there is no available APIs to check whether one archive can be read by java’s Zip APIs successfully. We think you can use the code that we used to show the Exception by iterating entries of the archive. If it gives exception, then you should use Apache’s zip tool instead.

Hi,

Thank you for your answer and suggestions.

I have one more question, are you planning to stop using java zip tool and start using apache zip tool for some future version of aspose.cells for java?

Regards,
Zeljko

@Zeljko,

Well, I am afraid, no, we cannot stop using java’s zip apis. The built-in zip apis of jdk is the most convenient way for common zip files for most users. Using additional third party library is not the first choice for users if it is not necessary.

For your information, when using apache’s zip tool, there is one disadvantage: we have to use template file while processing the archive. Although commonly the template file will be deleted automatically, there are still a few risks that some garbage would be left.

Thanks for your understanding!

@Zeljko,

Just to inform you, Aspose.Cells for Java v22.7 now supports to read OOXML format template files which contain abnormal zip data and that cannot be processed by java’s ZipInputStream itself.

In short, the source file can now be loaded from stream directly by Aspose.Cells for Java API. Please try our latest version/fix Aspose.Cells for Java v22.7 and let us know your feedback.