使用JXLS 1,可以通过简单的调用在Excel模板中进行替换
XLSTransformer.transformXLS(is,beans)例如,我们有bean对象,这些对象是这样组织的(不太好,ok.:):
class Person{
private String name;
private String lastname;
private String tel;
private String gender;
private Integer count;
public Person(String name, String lastname, String telephone, String gender){
this.name = name;
this.lastname = lastname;
this.tel = telephone;
this.gender = gender;
this.count = null;
}
public Person(String gender, int count){
this.gender = gender;
this.count = count;
}
//getters
}现在,给定这个模板:

并进行以下初始化:
List<Person> p = Arrays.asList(
new Person(„Johnny“, „Cash“, „1394567“, „M“),
new Person(„Paul“, „Newman“, „234667“, „M“),
new Person(„M“,2),
new Person(„Jessica“, „Alba“, „134566“, „F“),
new Person(„F“,1)
);
Map<String, List<? extends Object>> beans = new HashMap<String, List<? extends Object>>();
beans.put(„persons“, p);
beans.put(„heading“, Arrays.asList(„This is the heading“));一个简单的呼叫
transformer.transformXLS(templateInputStream, beans);就会产生出这样的结果:

现在,我需要迁移到JXLS 2,以便在非常大的XLSX文件中使用SXSSFWorkbook,但是我无法成功地将好的旧标记转换成它们的注释等价物:在网上文档中,我看到可以将更多的表达式组合在一起,但例如,jx:每个后面跟着一个jx:如果使用循环变量的会生成一个表达式EvaluationException。
你有什么可能有用的提示/例子吗?
提前感谢!
https://stackoverflow.com/questions/35067888
复制相似问题