pom.xml
<!-- easypoi -->
<dependency>
<groupId>org.jeecg</groupId>
<artifactId>easypoi-base</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>org.jeecg</groupId>
<artifactId>easypoi-annotation</artifactId>
<version>2.3.1</version>
</dependency>
导出信息的类class中需要导出的字段添加注解
@Excel(name = “XXXXX”, width = 60)
Excel导出模板:
/**
*
* 导出Excel表格模板
*
* @param calzz 导出类的calss
* @param dataList 导出类信息集合
* @param filePath 导出类名称
* @param response
**/
public static <T> void exportExeclTemplate(Class calzz, Collection<T> dataList, String filePath, HttpServletResponse response) throws Exception {
//导出报表
response.reset();
String fileName = new String(filePath.getBytes(),"ISO_8859_1");
//设置导出报表参数
ExportParams exportParams = new ExportParams(null, null, ExcelType.XSSF);
//创建工作簿
Workbook workBook = ExcelExportUtil.exportExcel(exportParams, calzz, dataList);
//定义报表名称
response.addHeader("Content-disposition", "attachment;filename="+fileName+".xls");
//定义输出类型
response.setContentType("octets/stream;charset=UTF-8");
//创建输出对象
ServletOutputStream out = response.getOutputStream();
//工作簿输出
workBook.write(out);
//关闭输出流
out.close();
}