共计 900 个字符,预计需要花费 3 分钟才能阅读完成。
实体类注解
@ContentRowHeight(int): | |
设置 row 高度,不蕴含表头 | |
标记在 类上 | |
@HeadRowHeight(int):设置 表头 高度(与 @ContentRowHeight 相同)标记在 类上 | |
@ColumnWidth(int):设置列宽 | |
标记在属性上 | |
@ExcelProperty(value = String[], index = int): | |
设置表头信息 | |
value: 表名称 | |
index: 列号 | |
##### 少用 | |
@DateTimeFormat:@NumberFormat:BrowsingExcelHistory browsingExcelHistory = new BrowsingExcelHistory(); | |
@Override | |
public WGJsonResult userFeedBackExport(UserFeedBack param, HttpServletResponse response) throws IOException {List<UserFeedBack> userFeedBackLists = userFeedBackMapper.getList(param); | |
response.setContentType("application/vnd.ms-excel"); | |
response.setCharacterEncoding("utf-8"); | |
SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy_MM_dd_hh_mm_ss"); | |
String nowDate = sdf4.format(new Date()); | |
String fileName = nowDate+ ".xlsx"; | |
response.setHeader("Content-disposition", "attachment;filename=" + fileName); | |
EasyExcel.write(response.getOutputStream(), UserFeedBack.class).sheet("用户反馈记录").doWrite(userFeedBackLists); | |
return success("下载胜利"); |
正文完
发表至: springboot
2021-08-04