How to resolve InvalidFormatException in xls file generated by jett?

269 views Asked by At

I have a bean with method to generate report made with 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();
    }

I'm having an InvalidFormatException in transformer.transfom (...):

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

I saw that it might be regarding the compatibility of the xls file with the libreoffice, or something. Thank you for any help.

1

There are 1 answers

0
philabreu On BEST ANSWER

I discovered that xls is actually being corrupted by maven ... when I try to open the file that is in the wildfly deploy folder it has already been corrupted ... I have tried some solutions to solve this problem of data corruption but I have not yet found it nothing that worked, but at least I already know what the real mistake is. Thank you.