Hi guys,
I upgraded the POI version in my program to 5.4.1, but it caused an issue that prevents the file from being converted to PDF.
When I revert the version back to 4.1.2, everything works fine.
We are currently using ASPOSE version 21.6 for the PDF conversion.
Here is the error message I encountered:
2025-07-07 22:58:46,144 ERROR RequestProcessor-5 [Server] Conversion failed
java.util.zip.ZipException: invalid entry size (expected 0 but got 1484 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.<init>(Unknown Source)
at com.aspose.cells.a.d.zg.a(Unknown Source)
at com.aspose.cells.a.d.zl.<init>(Unknown Source)
at com.aspose.cells.a.d.zl.a(Unknown Source)
at com.aspose.cells.zsp.a(Unknown Source)
at com.aspose.cells.zka.a(Unknown Source)
at com.aspose.cells.zka.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.<init>(Unknown Source)
at com.camline.stream2pdf.util.AsposeServices.convert(AsposeServices.java:49)
at com.camline.stream2pdf.Server.convert(Server.java:235)
at com.camline.stream2pdf.Server.convert(Server.java:206)
at com.camline.stream2pdf.Server.convert(Server.java:170)
at com.camline.server.stream2pdf.IServerPOA._invoke(IServerPOA.java:83)
at org.jacorb.poa.RequestProcessor.invokeOperation(RequestProcessor.java:402)
at org.jacorb.poa.RequestProcessor.process(RequestProcessor.java:726)
at org.jacorb.poa.RequestProcessor.run(RequestProcessor.java:884)
I’ve also attached our code snippet and two Excel files for your reference:
POI 5 test.zip (28.9 KB)
- POI 4 test.xlsx – works without any issue.
- POI 5 test.xlsx – causes the problem.
screenshot_20250708_144051.png (35.1 KB)
Could you help me figure out what might be causing this issue and how to resolve it?
Thank you very much!
@yi.xuan
Cause
The issue you’re encountering stems from the differences in how the newer version of Apache POI (5.4.1) handles Excel files compared to the older version (4.1.2). The error message indicates a problem with reading the ZIP structure of the Excel file, suggesting that the file created with POI 5.4.1 may not be compatible with the version of Aspose.Cells you are using (21.6).
Solution
To resolve this issue, follow these steps:
-
Check Compatibility: Ensure that the version of Aspose.Cells you are using supports the Excel file format generated by POI 5.4.1. Update Aspose.Cells to a newer version if necessary for better compatibility.
-
Validate the Excel File: Open the Excel file created with POI 5.4.1 in Excel to confirm it is not corrupted. If it opens without issues, the problem likely lies in how Aspose.Cells is handling the file.
-
Test with Different Formats: Save the Excel file in a different format (like XLSX or XLS) using POI 5.4.1 and check if that resolves the issue.
-
Review Code: Ensure that your code for converting the Excel file to PDF is correctly implemented and that you are not missing any required settings or configurations.
Code
Here’s a simple code snippet to check if the file can be opened with Aspose.Cells:
import com.aspose.cells.Workbook;
try {
Workbook workbook = new Workbook("path/to/your/POI5_test.xlsx");
workbook.save("output.pdf");
} catch (Exception e) {
e.printStackTrace();
}
Next Steps
- Update Aspose.Cells to the latest version if you haven’t already.
- Test the conversion with the provided code snippet.
- If the problem persists, reach out to Aspose support with the specific Excel files and error details for further assistance.
Please implement these steps and let me know if you need any further assistance!
@yi.xuan
By testing on the latest version v25.6 using sample files and the following sample code, we were able to run it normally without any exceptions.
LoadOptions options = new LoadOptions();
options.setMemorySetting(MemorySetting.MEMORY_PREFERENCE);
// Create workbook object
Workbook workbook = new Workbook(filePath + "POI 5 test.xlsx", options);
// Save the workbook in xlsx format
workbook.save(filePath + "out_java.xlsx", SaveFormat.XLSX);
We recommend you to kindly try using our latest version: Aspose.Cells for Java 25.6.
If you still find the issue, kindly do share your complete sample (runnable) code to reproduce the issue on our end, we will check it soon.
@yi.xuan
In fact the zip file that caused issue is not compatible with java’s zip api. If you use java’s ZipInputStream to load it and iterate entries and data in it, you will get the same exception. 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, for old versions of Aspose.Cells, 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 loaded from the InputStream and then use Java’s zip api to process the file.
We recommend you to upgrade Aspoe.Cells to latest versions, because we have implemented our own zip apis so there is no such kind of issue any more.
-DAspose.Cells.ZipTool=TEMPFILE is work. Thank you very much
@yi.xuan
Thank you for your feedback. You are welcome. I’m glad you solved the issue by using the suggested solution. If you have any questions, please feel free to contact us at any time.