EasyExcel 匯出時,自己拼表頭
阿新 • • 發佈:2020-07-31
要實現匯出這樣的一個表頭
下面程式碼就是返回以上的表頭
仔細看
private List<List<String>> getBaoHead(BaobiaoVO baobiaoVO){ List<List<String>> head = new ArrayList<>(); List<String> headerr = new ArrayList<>(); headerr.add(baobiaoVO.getFirstField()); head.add(headerr);if (StringUtils.hasText(baobiaoVO.getSecondField())) { List<String> itemCodeHeader = new ArrayList<>(); itemCodeHeader.add(baobiaoVO.getSecondField()); head.add(itemCodeHeader); } Map<String,List<String>> map = new HashMap<>(); List<String> headChildList = new ArrayList<>(); headChildList.add("專案數量"); headChildList.add("專案金額(元)"); headChildList.add("金額佔比"); map.put("平均毛利(評審毛利率)",headChildList); map.forEach((k,v) -> { String deviceCategory = k; List<String> ls = v; ls.forEach(e-> { List<String> headChild = new ArrayList<>(); headChild.add(deviceCategory); headChild.add(e); head.add(headChild); }); }); return head; }