vue+springmvc导出excel数据的实现代码

作者:袖梨 2022-06-25

vue端处理

this.$http.get(this.service + '/user/excel',{responseType: 'blob'}).then(({data})=> {
   console.info(typeof data)
   var a = document.createElement('a');
   var url = window.URL.createObjectURL(data);
   a.href = url;
   a.download = '用户统计信息.xls';
   a.click();
   window.URL.revokeObjectURL(url);
  })

web端处理

  int total=userBsService.getCount(null);
  List list=userBsService.getList(null, 1, total);
  String fileName = new Date().getTime() + "";
   XSSFWorkbook wb=new XSSFWorkbook();
   Sheet sheet=wb.createSheet();
   Row row0=sheet.createRow(0);
   String titleName[] = {"用户账号", "充值总金额", "邀请总人数", "社群组"};//列名
   for(int i=0;i

相关文章

精彩推荐