AngularJs带参数导出Excel表格

angular根据筛选的表格进行导出Excel表,或者全部导出表格。

 1  $scope.outExcel = function () {
 2         $http({
 3             method: 'GET',
 4             url: '/device/all/download',  
 5             params: {          //导出带的参数
 6                 'protocolVersion': $scope.protocolType,
 7                 'createTime': $scope.dateVal,
 8                 'deviceNum': $scope.pileNo,
 9                 'deviceStatus': $scope.deviceState
10             },
11             headers:{
12                     'Content-type': undefined
13             },
14             responseType: 'arraybuffer' 
15         }).then(function successCallback(resp) {
16             var blob = new Blob([resp.data], {type: "application/vnd.ms-excel"});//type:"applicatuib/vnd.ms-excel" 导出的文件类型 
18 var objectUrl = URL.createObjectURL(blob); 19 var a = document.createElement('a'); 20 document.body.appendChild(a); 21 a.setAttribute('style', 'display:none'); 22 a.setAttribute('href', objectUrl); 23 var filename = "devices.xls"; //文件扩展名 24 a.setAttribute('download',filename); 25 a.click(); 26 URL.revokeObjectURL(objectUrl); 27 }) 32 }

 

转载于:https://www.cnblogs.com/nanabing/p/9815229.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值