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);
});
};


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM