依赖工具包
cn.hutool
hutool-all
5.3.5
该工具包是对 Apache POI包的分装
private void export(HttpServletResponse response, String fileName, List> projects, List columns) throws IOException {
ExcelWriter bigWriter = ExcelUtil.getBigWriter();
//创建一行空表头占个位置
bigWriter.writeHeadRow(new LinkedList());
//创建需要展示的的二级表头,{filedName,中文名}
int lastCol = 0;
for (int i = 0; i < columns.size(); i++) {
if (columns.get(i).getChildren() != null) {
for (int j = 0; j < columns.get(i).getChildren().size(); j++) {
bigWriter.addHeaderAlias(columns.get(i).getChildren().get(j).getProp(), columns.get(i).getChildren().get(j).getLabel() + columns.get(i).getProp());
bigWriter.setColumnWidth(lastCol++, 30);
}
}
}
//根据需要合并添加第一列表头