js 导出Excel2

// 点击导出Excel
$(document).on("click", "button.excel", (res) => {
qqkj.getExcel(res);
});

/**
保单列表
* 导出Excel
* @param callback 回调函数
*/
qqkj.getExcel = function(callback) {
var _this = this;
console.log(_this.getCookie("token"));
$.ajax({
beforeSend: function(request) {
request.setRequestHeader('token', _this.getCookie("token"))
},
type: "get",
cache: false,
data: '',
url: _this.url + '/uc/admin/policy/export/excel.xls',
success: function(data) {
if (data) {
callback(window.open(_this.url + '/uc/admin/policy/export/excel.xls?token='+_this.getCookie("token"), '_blank', ''));
} else {
alert("ERROR!");
}
},
error: function(response) {
console.log(response.statusText);
}

})
};

原文地址:https://www.cnblogs.com/linyongli/p/9087225.html