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}}