How to resolve ioexception in xls file generated by Jett?

Asked

Viewed 10 times

0

Guys I have a bean with way to generate report so done with Jett:

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

    beans.put("fichasTecnicasMateriaPrimaResumo", fichasTecnicasMateriaPrimaResumo);
    try {
         ExcelTransformer transformer = new ExcelTransformer();
         transformer.transform("template.xls", "precificacao.xls", beans);
    } catch (IOException e) {
        System.err.println("IOException reading " + "template.xls" + ": " + e.getMessage());
    } catch (InvalidFormatException e) {
        System.err.println("InvalidFormatException reading " + "template.xls" + ": " + e.getMessage());
    }

I’m having an Ioexception just on Transformer.transfom(...) and I put template.xls in the same bean folder; in fact I did the same with Jett’s documentation and they don’t explain much there. Any help is welcome!

1 answer

0


I decided by passing the entry as Inputstream No String:

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();
}

The documentation of Jett says nothing about this, I find even a little poor.

Browser other questions tagged

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