|
|
@@ -38,6 +38,22 @@ public class ExcelUtils<T> {
|
|
|
.doWrite(data);
|
|
|
}
|
|
|
|
|
|
+ public static void export1(HttpServletResponse response, Class<?> clazz) throws IOException {
|
|
|
+ String fileName = clazz.getSimpleName() + ".xlsx";
|
|
|
+ ApiModel apiModel = clazz.getAnnotation(ApiModel.class);
|
|
|
+ if (apiModel != null) {
|
|
|
+ if (StringUtils.isNotEmpty(apiModel.value())) {
|
|
|
+ fileName = apiModel.value() + ".xlsx";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ response.setContentType("application/vnd.ms-excel");
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
|
|
|
+ EasyExcel.write(response.getOutputStream(), clazz).sheet("sheet")
|
|
|
+ .doWrite(null);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 从Excel中读取文件,读取的文件是一个DTO类,该类必须继承BaseRowModel
|
|
|
* 具体实例参考 : MemberMarketDto.java
|