使用jxls按模板导出excel数据

public class StyleRowSample {
    private static String templateFileName = "/templates/rowstyle.xls";
    private static String destFileName = "build/rowstyle_output.xls";

    public static void main(String[] args) throws IOException, ParsePropertyException, InvalidFormatException {
        if (args.length >= 2) {
            templateFileName = args[0];
            destFileName = args[1];
        }
        Department department = new Department("IT");
        Calendar calendar = Calendar.getInstance();
        calendar.set(1970, 12, 2);
        Date d1 = calendar.getTime();
        calendar.set(1980, 2, 15);
        Date d2 = calendar.getTime();
        calendar.set(1976, 7, 20);
        Date d3 = calendar.getTime();
        calendar.set(1968, 5, 6);
        Date d4 = calendar.getTime();
        calendar.set(1978, 8, 17);
        Date d5 = calendar.getTime();
        department.addEmployee(new Employee("Elsa", 28, 1500, 0.15, d1));
        department.addEmployee(new Employee("Oleg", 32, 2300, 0.25, d3));
        department.addEmployee(new Employee("Neil", 34, 2500, 0.00, d4));
        department.addEmployee(new Employee("Maria", 34, 1700, 0.15, d5));
        department.addEmployee(new Employee("John", 35, 2800, 0.20, d2));
        Map beans = new HashMap();
        beans.put("department", department);
        XLSTransformer transformer = new XLSTransformer();
        transformer.registerRowProcessor(new StyleRowProcessor("department.staff"));
        transformer.transformXLS(StyleRowSample.class.getResource(templateFileName).getPath(), beans, destFileName);
    }

}





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值