Java Excel导出
标签:string put bsp ati width turn get ring 项目
package com.gome.budget.common.utils;
import com.alibaba.excel.EasyExcelFactory;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.metadata.Sheet;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
public class ExcelExportUtil {
public static void main(String[] args) throws FileNotFoundException {
List> header = createTestListStringHead();
List> dataLists = createTestListObject();
OutputStream os = new FileOutputStream("D:\\share\\expense.xlsx");
ExcelExportUtil exporter = new ExcelExportUtil();
exporter.initWriter(os);
exporter.createSheet(1, 0, "损益表2", header)
.writeDatas(dataLists);
exporter.createSheet(2, 0, "费用表2", header)
.writeDatas(dataLists);
exporter.close();
}
public ExcelExportUtil() {
}
public static List> createTestListStringHead() {
List> header = new ArrayList>();
List headList = new ArrayList();
headList.add("预算组织");
header.add(headList);
headList = new ArrayList();
headList.add("项目");
header.add(headList);
headList = new ArrayList();
headList.add("前2个考核期实际数");
header.add(headList);
headList = new ArrayList();
headList.add("前1个考核期发生月实际数");
header.add(headList);
headList = new ArrayList();
headList.add("前1个考核期未发生月预测数");
header.add(headList);
headList = new ArrayList();
headList.add("前1个考核期预测数");
header.add(headList);
headList = new ArrayList();
headList.add("当前考核期上报数");
header.add(headList);
headList = new ArrayList();
headList.add("同比");
header.add(headList);
headList = new ArrayList();
headList.add("环比");
header.add(headList);
return header;
}
public static List> createTestListObject() {
List> dataList = new ArrayList>();
List
Java Excel导出
标签:string put bsp ati width turn get ring 项目
原文地址:https://www.cnblogs.com/honghong75042/p/11047759.html
评论