JXSL报错CannotOpenWorkbookException和NotOfficeXmlFileException解决方案
1.最开始配置的过滤,在本地运行和发自己搭建的服务器没问题 可以正常excel下载包里面exce可以正常打开。2.使用云服务docker 打包镜像之后excel 就损坏了无法打开 ,让人头疼。-- 过滤后缀文件 -->一.报错信息分析说的找不到file 下面是控制台报错。然后就想会不会过滤文件的不彻底 应该在根就过滤。-- 过滤后缀文件 -->templates 是存放excel模板文件名。然后重
一.报错信息分析 说的找不到file 下面是控制台报错
org.apache.poi.openxml4j.exceptions.NotOfficeXmlFileException: No valid entries or contents found, this is not a valid OOXML (Office Open XML) file
2023-10-23T03:12:24.949415079Z org.jxls.util.CannotOpenWorkbookException: org.apache.poi.openxml4j.exceptions.NotOfficeXmlFileException: No valid entries or contents found, this is not a valid OOXML (Office Open XML) file
1.最开始配置的过滤,在本地运行和发自己搭建的服务器没问题 可以正常excel下载 包里面exce可以正常打开。
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <configuration> <encoding>UTF-8</encoding> <!-- 过滤后缀文件 --> <nonFilteredFileExtensions> <nonFilteredFileExtension>docx</nonFilteredFileExtension> <nonFilteredFileExtension>xlsx</nonFilteredFileExtension> </nonFilteredFileExtensions> </configuration> </plugin>
2.使用云服务docker 打包镜像之后excel 就损坏了无法打开 ,让人头疼。
然后就想会不会过滤文件的不彻底 应该在根就过滤。
然后配置文件改成这样
templates 是存放excel模板文件名
<build> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> <excludes> <exclude>templates/*.xlsx</exclude> </excludes> </resource> <resource> <directory>src/main/resources</directory> <filtering>false</filtering> <includes> <include>templates/*.xlsx</include> </includes> </resource> </resources> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <configuration> <encoding>UTF-8</encoding> <!-- 过滤后缀文件 --> <nonFilteredFileExtensions> <nonFilteredFileExtension>docx</nonFilteredFileExtension> <nonFilteredFileExtension>xlsx</nonFilteredFileExtension> </nonFilteredFileExtensions> </configuration> </plugin> </plugins> </build>
然后重新编译打包 然后 好了 完结撒花
更多推荐
所有评论(0)