Search code examples
jxls

WARN org.apache.commons.jexl2.JexlEngine - org.jxls.expression.JexlExpressionEvaluator.evaluate@61![0,11] undefined variable


i am getting undefined variable error in excel generation my code is following

ApplicationContext context=new ClassPathXmlApplicationContext("bean.xml");
        EmployeeList employees=context.getBean("employeelist", EmployeeList.class);
        InputStream is = getClass().getClassLoader().getResourceAsStream("EmployeeTemplate1.xlsx");
        List<Employee>list=employees.getList();
        try {
            OutputStream os = new FileOutputStream("target/object_collection_output.xls");
            Context context1 =new Context();
            context1.putVar("list",list);
            JxlsHelper.getInstance().processTemplate(is, os, context1);
            is.close();
            os.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

Solution

  • The exception indicates that Jexl engine could not resolve a variable used in the template expression.

    The variable name is usually noted in the warning.

    This may happen for example if you misspelled an object attribute name or if the property is inaccessible (check that you have a public getter method properly named).