现象:
在JAVA的resources文件夹中放置了execl模板,想要在读取模板的基础上编辑并下载,结果在转换为workbook时,报以下问题:
org.apache.poi.openxml4j.exceptions.InvalidOperationException: Could not open the specified zip entry source streamorg.apache.poi.openxml4j.opc.ZipPackage.openZipEntrySourceStream(ZipPackage.java:205)org.apache.poi.openxml4j.opc.ZipPackage.openZipEntrySourceStream(ZipPackage.java:187)org.apache.poi.openxml4j.opc.ZipPackage.openZipEntrySourceStream(ZipPackage.java:161)......
解决:
maven编译命令中追加相关除外条件解决,详见以下的nonFilteredFileExtension配置:
<plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-resources-plugin</artifactId><version>3.0.2</version><configuration><encoding>utf-8</encoding><useDefaultDelimiters>true</useDefaultDelimiters><nonFilteredFileExtensions><nonFilteredFileExtension>cer</nonFilteredFileExtension><nonFilteredFileExtension>jks</nonFilteredFileExtension><nonFilteredFileExtension>p12</nonFilteredFileExtension><!-- 需要过滤掉不需要编码的文件:过滤后缀为以下的所有文件,不对其进行统一编码--><nonFilteredFileExtension>xlsx</nonFilteredFileExtension><nonFilteredFileExtension>xls</nonFilteredFileExtension><nonFilteredFileExtension>docx</nonFilteredFileExtension><nonFilteredFileExtension>doc</nonFilteredFileExtension></nonFilteredFileExtensions></configuration>
</plugin>