I am trying to open existing xlsx file (Ms-excel 2010) to append with more data using Apache-POI (v 3.15).
The existing xlsx file (size 700Kb) contains number of tabs with pivot tables, charts etc.
File file = new File(FILE_PATH);
OPCPackage opcPackage = OPCPackage.open(file);
XSSFWorkbook wbk = new XSSFWorkbook(opcPackage);
But the exception thrown is as below,
Caused by: java.io.IOException: Zip bomb detected! The file would exceed the max. ratio of compressed file size to the size of the expanded data. This may indicate that the file is used to inflate memory usage and thus could pose a security risk. You can adjust this limit via ZipSecureFile.setMinInflateRatio() if you need to work with files which exceed this limit. Counter: 819241, cis.counter: 8192, ratio: 0.009999499536766349Limits: MIN_INFLATE_RATIO: 0.01 at org.apache.poi.openxml4j.util.ZipSecureFile$ThresholdInputStream.advance(ZipSecureFile.java:257)
I have tried following changes:
1. tried to change "ZipSecureFile.setMinInflateRatio()" to fix tihs, but JVM crashes with heap space error (even though I allocated more than 4GB)
2. tried to use inputsteam, Workbookfactory.create to create workbook, tried to open as SXSSF.
But none of this has worked for me. Any one has any idea ?