一 操作案例
1.1 pom文件
<groupId>net.sf.jett</groupId>
<artifactId>jett-core</artifactId>
<version>0.11.0</version>
1.2 代码
@RequestMapping("/export")
public void exportEnvCycleExcel(HttpServletResponse response) {
Map<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put("titleName","环保指标报表");
resultMap.put("reportDate", DateUtils.dateToStr(new Date(),"yyyy-MM-dd"));
//List<Student> studentsList=new ArrayList<>();
List<Map> studentsList=new ArrayList<>();
Map<String,Object> map=new LinkedHashMap<>();
resultMap.put("dataList",studentsList);
buildExcelReport( resultMap, response);
public void buildExcelReport(Map<String, Object> resultMap, HttpServletResponse response){
String modelFile="d:/model-test.xlsx";
try (InputStream is = new FileInputStream(new File(modelFile));) {
Workbook workbook = new ExcelTransformer().transform(is, resultMap);
buildExcelDocument("环保_"+System.currentTimeMillis()+".xlsx", workbook, response);
protected static void buildExcelDocument(String filename, Workbook workbook, HttpServletResponse response)
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "utf-8"));
OutputStream outputStream = response.getOutputStream();
workbook.write(outputStream);

1.3 excel模板
${t.id} ${t.name} ${t.age}

1.4 导出效果
