Angular 导出Excel 表格

来源:互联网 发布:淘宝吧 编辑:程序博客网 时间:2024/06/05 21:04

//导出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

原创粉丝点击