Easy Excel导出

@GetMapping(value = "/down2")
    public void down2(HttpServletResponse response) throws Exception{
        ExcelTypeEnum type=ExcelTypeEnum.XLSX;
        response.setContentType("multipart/form-data");
        response.setCharacterEncoding("utf-8");
        response.setHeader("Content-disposition", "attachment;filename=" + "default" + type.getValue());
        ServletOutputStream out = response.getOutputStream();
        ExcelWriter writer = new ExcelWriter(out, type, true);

        List clsList=new ArrayList();
        Person per=new Person();
        per.setName("ww");
        per.setAge("33");
        Person per2=new Person();
        per.setName("ww");
        per.setAge("33");
        clsList.add(per);
        clsList.add(per2);

        Sheet sheet1=new Sheet(1,0,Person.class);
        sheet1.setSheetName("ww");
        writer.write(clsList,sheet1);
        //writer.write(SheetNameAndDateList, writer);
        writer.finish();
        out.flush();

    }

 

你可能感兴趣的:(Easy Excel导出)