Springboot导出百万级数据到excel

您所在的位置:网站首页 oracle导出百万数据到excel Springboot导出百万级数据到excel

Springboot导出百万级数据到excel

2023-08-19 03:27| 来源: 网络整理| 查看: 265

最近项目有导出数据到excel功能,于是觉得很轻松的写了下面代码

@ApiOperation(value = "万级数据导出") @RequestMapping(value = "/export1",method = RequestMethod.GET) public void exportExcel1(HttpServletResponse response, HttpServletRequest request) throws Exception{ //接收参数 String accounttime = request.getParameter("accounttime"); //创建poi导出数据对象 //SXSSFWorkbook sxssfWorkbook = new SXSSFWorkbook(); //创建sheet页 //SXSSFSheet sheet = sxssfWorkbook.createSheet("测试1"); XSSFWorkbook sxssfWorkbook = new XSSFWorkbook(); XSSFSheet sheet = sxssfWorkbook.createSheet("测试1"); //创建表头 XSSFRow headRow = sheet.createRow(0); //设置表头信息 headRow.createCell(0).setCellValue("序号"); headRow.createCell(1).setCellValue("姓名"); headRow.createCell(2).setCellValue("年龄"); // 遍历上面数据库查到的数据 for(int i =1;i


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3