How to solve InvalidFormatException in xls file generated by jett?

0

I have a 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

When I change the file extension to .ods the exception changes:

12:46:34,703 ERROR [stderr] (default task-57) java.util.zip.ZipException: unexpected EOF

I generated the files by microsoft office and libreoffice and both gave an error.

    
asked by anonymous 04.09.2017 / 17:53

1 answer

0

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 more I still do not find anything that works, but at least I already know what the real mistake is.

    
05.09.2017 / 21:21