Angularjs 导出excel表格

//导出excel表
$scope.exportOrder = function () {
$scope.datetime.startTime=$scope.year+"-"+ $scope.lastmounth+"-"+$scope.lastday;
$scope.datetime.endTime=$scope.yearD+"-"+ $scope.mounthD+"-"+"25";
$scope.datetime.type= $scope.selectway;
$http({
url: 'kpis/export/inp',
method: "POST",
headers: {
'Content-type': 'application/json'
},
params: $scope.datetime,
responseType: 'arraybuffer'
}).success(function (data) {
var blob = new Blob([data], {type: "application/vnd.ms-excel"});
var objectUrl = URL.createObjectURL(blob);
var filename="报表"+$scope.yearD+"-"+ $scope.mounthD+'.xls';
if (window.navigator.msSaveOrOpenBlob) {// For IE:
navigator.msSaveBlob(blob, filename);
}else{ // For other browsers:
URL.revokeObjectURL(objectUrl);
}
}).error(function(data){
alert(data.message);
});
};
原文地址:https://www.cnblogs.com/liucong7708/p/6677010.html