利用easyExcel将数据导出到模板
复制代码
public class BsMatrixConsortiumBo{

    private Long id;

   private String applyScopeConsortium;

  private String companyPointNo;

   private String standardPointNo;

   private String businessProcess;

   private String sonProcess;

   private String controlTarget;

  private String companyPointMessage;

  private String standardPointMessage;

    private String controlRate;

   private String controlType;

  private String controlClass;

 private String suggestDutyDept;

  private String companyDutyDept;
private String companyPointUser;

  private String nkDesignDutyDept;

   private String nkProcessUser;

 private String pointExecuteTime;

  private String itWeldingMode;

  private String weldingSystem;

  private String pointClass;

   private String trajectionTestData;

   private String referenceFile;

   private String suggestFollow;

  private String year;

    private String matrixType;


}
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
List<BsMatrixConsortiumVo> list = iBsMatrixConsortiumService.queryList(bo);
        for (int i = 0; i < list.size(); i++) {
            int index = i + 1;
            list.get(i).setId(Long.parseLong(index + ""));//序号
        }
        BufferedOutputStream bos = null;
        String temPath = fileTemplatesDir + "集团矩阵.xlsx";
        response.setContentType("application/vnd.ms-excel");
        response.setCharacterEncoding("utf-8");
        response.setHeader("Content-disposition", "attachment;filename=内控矩阵excel");
        try {
            bos = new BufferedOutputStream(response.getOutputStream());
            ExcelWriter excelWriter = EasyExcel.write(bos).withTemplate(temPath).build();
            WriteSheet writeSheet = EasyExcel.writerSheet().build();
            excelWriter.fill(list,writeSheet);
            excelWriter.finish();
            bos.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }

  

 

posted on   小吴编  阅读(306)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示