如何解决 jett 生成的 xls 文件中的 InvalidFormatException?

How to resolve InvalidFormatException in xls file generated by jett?

我有一个 bean,它有方法生成用 jett 制作的报告:

Map<String, Object> beans = new HashMap<String, Object>();

    beans.put("fichasTecnicasMateriaPrimaResumo", fichasTecnicasMateriaPrimaResumo);

    try {

        InputStream inPath = ProdutoManagedBean.class.getResourceAsStream("/template.xls");

        ExcelTransformer transformer = new ExcelTransformer();
        transformer.transform(inPath, beans);
    } catch (IOException e) {
        e.printStackTrace();
    } catch (InvalidFormatException e) {
        e.printStackTrace();
    }

我在 transformer.transfom 中遇到 InvalidFormatException (...):

22:44:37,803 ERROR [stderr] (default task-28) org.apache.poi.openxml4j.exceptions.InvalidFormatException: Your InputStream was neither an OLE2 stream, nor an OOXML stream

我看到可能是关于xls文件与libreoffice的兼容性之类的。感谢您的帮助。

我发现 xls 实际上被 maven 损坏了……当我尝试打开 wildfly 部署文件夹中的文件时,它已经被损坏了……我已经尝试了一些解决方案来解决这个问题数据损坏,但我还没有发现它没有任何作用,但至少我已经知道真正的错误是什么。谢谢。