使用jxls导出excel报错:Your InputStream was neither an OLE2 stream, nor an OOXML stream

最近接到导出excel报表的需求,本来想用poi的,听说jxls更简单快捷,便想试试。一开始demo写的都挺顺利的,把excel模板放到项目的resources下面后,出事了,一直报错:

         java.lang.IllegalArgumentException: Your InputStream was neither an OLE2 stream, nor an OOXML stream

在网上找了好久,终于解决。

      原因: maven打包插件打包时,修改了excel模板文件,导致excel模板文件损坏,无法打开。

      解决方法:maven打包时不修改excel文件,pom.xml中打包插件配置如下:


    org.apache.maven.plugins
    maven-resources-plugin
   
        UTF-8
       
            xlsx
            xls
       

   

 

你可能感兴趣的:(使用jxls导出excel报错:Your InputStream was neither an OLE2 stream, nor an OOXML stream)