关于springboot:springboot下的Excel到出

实体类注解

@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("下载胜利");

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理