const xhr = new XMLHttpRequest();
xhr.open('get', 'http://192.168.0.150:8080/excel/export');
xhr.responseType = "blob";
xhr.addEventListener('load', () => {
if (xhr.status === 200) {
// var blob = new Blob([xhr.responseText], { type: "application/vnd.ms-excel" });//2003
var blob = new Blob([xhr.response], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;" }); // 2007
var url = window.URL.createObjectURL(blob);
let a = document.createElement("a");
a.href = url
a.download = '信息表.xlsx';
a.click();
}
});
xhr.send();
XMLHttpRequest 下载excel文档
于 2022-04-21 13:35:04 首次发布