Jett, poi, jexl. Cannot transform my document

736 views Asked by At

I'm trying to transform my workbook with Jett like this:

HashMap<String, Object> tm = new HashMap<String, Object>();
tm.put("mod", "123");
ExcelTransformer t = new ExcelTransformer();
t.transform(wb, tm);

In the document there is a cell with such value ${mod} Every time I run this code, I get an exception

org.apache.commons.jexl2.parser.ParseException: parse error
at org.apache.commons.jexl2.parser.Parser.generateParseException(Parser.java:3935)
at org.apache.commons.jexl2.parser.Parser.jj_consume_token(Parser.java:3817)
at org.apache.commons.jexl2.parser.Parser.JexlScript(Parser.java:74)
at org.apache.commons.jexl2.parser.Parser.parse(Parser.java:24)
at net.sf.jett.expression.Expression.getValueIndicatingImplicitCollection(Expression.java:272)
at net.sf.jett.expression.Expression.getImplicitCollectionExpr(Expression.java:346)
at net.sf.jett.transform.CellTransformer.transform(CellTransformer.java:103)
at net.sf.jett.transform.BlockTransformer.transform(BlockTransformer.java:72)
at net.sf.jett.transform.BlockTransformer.transform(BlockTransformer.java:34)
at net.sf.jett.transform.SheetTransformer.transform(SheetTransformer.java:69)
at net.sf.jett.transform.ExcelTransformer.transform(ExcelTransformer.java:353)

I tried to write in brackets some other example values. They are all working fine. But when I try to mention some bean from the bean map, it raises an exception. Please help.

1

There are 1 answers

0
Pavel On BEST ANSWER

The word "mod" is a reserved word, so don't use it as a name of the data "model" you want to mention in JEXL bean context.