Easyexcel 导出excel

 @GetMapping("/exportExcel")
    public void exportExcel(HttpServletResponse response) throws IOException {
        QueryWrapper objectQueryWrapper = new QueryWrapper<>();
        List itemLibraryVos = itemsMapper.selectList(objectQueryWrapper);
        System.out.println(itemLibraryVos);
         //设置导出格式
        response.setContentType("application/vnd.ms-excel");
        response.setCharacterEncoding("utf-8");
        //导出数据  DtbsItem为实体类    itemLibraryVos 为数据库中查出的数据
        EasyExcel.write(response.getOutputStream(), DtbsItem.class).sheet("品规信息表").doWrite(itemLibraryVos);
    }

你可能感兴趣的:(excel,java,前端)