use of com.hb0730.boot.admin.project.system.post.model.dto.PostExcelDTO in project boot-admin by hb0730.
the class PostController method export.
/**
* 导出
*
* @param response 响应
* @param params 请求参数,用于导出过滤
* @throws ExportExceptions 导出异常
*/
@Override
@PostMapping("/export")
@Log(value = "导出", paramsName = { "params" }, businessType = BusinessTypeEnum.EXPORT)
@PreAuthorize("hasAnyAuthority('ROLE_ADMINISTRATOR','post:export')")
public void export(HttpServletResponse response, @RequestBody PostParams params) throws ExportExceptions {
List<PostExcelDTO> export = service.export(params);
HashMap<String, Object> map = Maps.newHashMap();
try {
map.put(ExcelConstant.FILE_NAME, "post_excel");
map.put(ExcelConstant.DATA_LIST, export);
ExcelUtils.writeWeb(response, map, ExcelTypeEnum.XLS, PostExcelDTO.class);
} catch (Exception e) {
e.printStackTrace();
throw new ExportExceptions("岗位导出失败", e);
}
}
use of com.hb0730.boot.admin.project.system.post.model.dto.PostExcelDTO in project boot-admin by hb0730.
the class ExcelUtilsTest method writeTest.
@Test
public void writeTest() throws IOException {
ExcelProperties properties = new ExcelProperties("C:\\Users\\12780\\Downloads", "test", ExcelTypeEnum.XLS, PostExcelDTO.class);
OutputStream outputStream = ExcelUtils.getOutputStream(properties);
List<PostExcelDTO> data = Lists.newArrayList();
data.add(new PostExcelDTO("S001", "全栈开发", 1, new Date()));
data.add(new PostExcelDTO("S002", "全栈开发", 1, new Date()));
data.add(new PostExcelDTO("S003", "全栈开发", 1, new Date()));
data.add(new PostExcelDTO("S004", "全栈开发", 1, new Date()));
ExcelUtils.write(outputStream, data, ExcelTypeEnum.XLS, PostExcelDTO.class);
}
Aggregations