如何在XSLT模板转换中编写像求和这样的公式

时间:2013-04-03 11:06:46

标签: java xslt xls xlsx

在我的程序中

Map<String, Collection<Employee>> beans = new HashMap<String, Collection<Employee>>();
        beans.put("employee", staff);
        XLSTransformer transformer = new XLSTransformer();
        try {
            transformer.transformXLS("C:/Users/hussain.a/Desktop/newprojectpocdetails/temp (Autosaved).xls", beans, "C:/Users/hussain.a/Desktop/newprojectpocdetails/demo.xls");

我正在设置单元格公式,例如$ {employee.field1},$ {employee.field2} 它运作正常

但在接下来的几列中,我需要对从对象中检索到的值进行一些计算, 所以我写了

${employee.field1} + ${employee.field2}
// not working but results in string 1 followed by string 2
// say field1=3 , field=4 , output cell has 3+4 not 7
=sum(${employee.field1} ,${employee.field2})
// not working says error
=sum(${employee.field+employee.field2})
// not working says error

如何正确编写公式以在输出xls表中获得所需的计算

0 个答案:

没有答案