import org.jxls.common.Context;
import org.jxls.util.JxlsHelper;
public class JXLSExample {
public static void main(String[] args) {
try {
try (InputStream is = new FileInputStream("template.xlsx")) {
try (OutputStream os = new FileOutputStream("output.xlsx")) {
Context context = new Context();
List<Person> persons = Arrays.asList(
new Person("John", 25),
new Person("Jane", 30),
new Person("Tom", 35)
);
context.putVar("persons", persons);
JxlsHelper.getInstance().processTemplate(is, os, context);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
class Person {
private String name;
private int age;
// ...
}