How to solve ioexception in xls file generated by jett?

0

I have a bean with method 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 in transformer.transfom (...), and I put template.xls in the same folder as the bean; in fact I did equal the documentation of the jett and they do not explain much the. Any help is welcome!

    
asked by anonymous 02.09.2017 / 22:40

1 answer

0

I solved passing the input as InputStream not 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 the jett does not say anything about this, I think even a little poor.

    
04.09.2017 / 03:41