'POI - ZIP entry size is too large

I use JXLS to create my woorkbook. JXLS uses POI underneath. To create a workbook JXLS either need a File or an input stream.

With file object I get my desired woorkbook. But, with stream I get error ZIP entry size is too large.

JXLS lib use

WorkbookFactory.create()

method to create workbook. So, I tried with ZipStream and PushbackStream; no help. I was able to run the same code from my Junit.

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

The solution form the post is, a change in Maven. But, the post did not mentioned about the change made in Maven.

Do you have any suggestions?



Solution 1:[1]

I found the issue. The issue is Maven is ignoring the files I kept inside my resources. So i added resource filtering like below to include my excel templates.

<resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
            <excludes>
                <exclude>**/*.xlsx</exclude>
            </excludes>
        </resource>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>false</filtering>
            <includes>
                <include>**/*.xlsx</include>
            </includes>
        </resource>
</resources>

Solution 2:[2]

For my project, I added these so excel and word documents are not compressed

<pluginManagement>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <version>2.6</version>
            <artifactId>maven-resources-plugin</artifactId>
            <configuration>
                <encoding>UTF-8</encoding>
                <nonFilteredFileExtensions>
                    <nonFilteredFileExtension>xlsx</nonFilteredFileExtension>
                    <nonFilteredFileExtension>docx</nonFilteredFileExtension>
                </nonFilteredFileExtensions>
            </configuration>
        </plugin>
    </plugins>
</pluginManagement>

Solution 3:[3]

In my case the issue was due to the fact that Java was opening the file

    InputStream fileStream = getClass().getResourceAsStream("path/to/excel/file.xlsx");
    Workbook workbook = new XSSFWorkbook(fileStream);

while the file was also opened in Excel. I closed Excel and the error went away.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Panda1667075
Solution 2 fall
Solution 3 Roberto Petrilli