900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > EasyPOI导出Excel尾部追加自定义内容操作

EasyPOI导出Excel尾部追加自定义内容操作

时间:2018-12-28 14:31:35

相关推荐

EasyPOI导出Excel尾部追加自定义内容操作

if (list != null && list.size() > 0) {map.put("list", list);// 模板路径String pathname = "/export/";String excelTemplateUrl = pathname + "shmc.xlsx";// 设置导出参数TemplateExportParams params = new TemplateExportParams(UtilCodeService.convertTemplatePath(excelTemplateUrl),true);params.setStyle(ExcelStyleType.BORDER.getClazz());Workbook book = ExcelExportUtil.exportExcel(params, map);//再数据末尾填需要额外提示的提示内容Sheet sheet = book.getSheetAt(0);//总列数,该模板中表头标题占两列int totalIndex = list.size()+2;//要写入的列数,与数据空一格int rightIndex = totalIndex+2;Row row = sheet.getRow(rightIndex);if (null ==row){row = sheet.createRow(rightIndex);}Cell cell = row.getCell(0);if ( null == cell){cell = row.createCell(0);}cell.setCellType(Cell.CELL_TYPE_STRING);cell.setCellValue(" 就是这里哈哈哈哈哈哈。");response.setContentType("application/vnd.ms-excel;charset=utf8");String excelName = "汇总表" + ".xlsx";response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(excelName, "UTF-8"));// 导出OutputStream outputStream = response.getOutputStream();book.write(outputStream);outputStream.flush();outputStream.close();}

2,或者在模板中将! 改为$ 不覆盖向下插入:{{$fe:list t.xh}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。