Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why am I getting exception "IOException: ZIP entry size is too large" when trying to open an Excel file using Apache POI?

The problem is the same as described here

But since no solution found there, trying to reopen the topic here? In short, I'm using Apache POI 3.8. I have a *.xlsm file with Macros in it. I am trying to open this file while the application is deployed, but getting the error inside "XSSFWorkbook" constructor which says that "ZIP entry size is too large". The strange part is that I am able to perform that operation locally in my IDEA without any problems. Would appreciate if someone would share the ideas of what is happening, if any had such issue in the past.

like image 901
LaRRy Avatar asked Apr 07 '14 17:04

LaRRy


2 Answers

Glancing a bit through the related code, my guess is that it depends on where the file is located. Possibly if it is a File then poi is handling it differently than if it is some other source (e.g. in memory)?

If that is the case, then you could probably solve the problem by writing the file to a temporary file and then loading it into poi. Specifically, if you create an XSSFWorkbook from a File, you should not hit this issue. According to the javadoc, you do this:

   OPCPackage pkg = OPCPackage.open(path);
   XSSFWorkbook wb = new XSSFWorkbook(pkg);
   // work with the wb object
   ......
   pkg.close(); // gracefully closes the underlying zip file
like image 107
jtahlborn Avatar answered Nov 15 '22 07:11

jtahlborn


So the reason was that Maven was corrupting template file when building application archive.

like image 28
LaRRy Avatar answered Nov 15 '22 05:11

LaRRy