How to resolve Invalidformatexception in xls file generated by Jett?

Asked

Viewed 44 times

0

I have a way of generating reports done 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 am having an Invalidformatexception on 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 switch the file extension to . ods the Exception changes:

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

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

1 answer

0


I found out that actually the xls is getting corrupted by Maven...when I try to open the file that is in the wildfly deploy folder it already comes corrupted...I searched some solutions to resolve this data corruption issue but still haven’t found anything that works, but at least now I know what the real mistake is.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.