easyexcle 导出csv

导入jar

 
            com.alibaba
            easyexcel
            3.3.3
        
代码
 private static List<List<String>> head() {
        List<List<String>> list = ListUtils.newArrayList();
        List<String> head0 = ListUtils.newArrayList();
        head0.add("字符串" + System.currentTimeMillis());
        List<String> head1 = ListUtils.newArrayList();
        head1.add("数字" + System.currentTimeMillis());
        List<String> head2 = ListUtils.newArrayList();
        head2.add("日期" + System.currentTimeMillis());
        list.add(head0);
        list.add(head1);
        list.add(head2);
        return list;
    }

    private static List<List<Object>> dataList() {
        List<List<Object>> list = ListUtils.newArrayList();
        for (int i = 0; i < 10; i++) {
            List<Object> data = ListUtils.newArrayList();
            data.add("字符串" + i);
            data.add(0.56);
            data.add(new Date());
            list.add(data);
        }
        return list;
    }

    public static void main(String[] args) {

        String fileName = "/opt/test.csv";
        EasyExcel.write(fileName).excelType(ExcelTypeEnum.CSV).head(head()).sheet("模板").doWrite(dataList());
    }

官方

你可能感兴趣的:(csv,easyexcle,excel)