Reputation: 147
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?
Upvotes: 2
Views: 10314
Reputation: 857
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.
Upvotes: 0
Reputation: 1202
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>
Upvotes: 2
Reputation: 147
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>
Upvotes: 10