我正在进行Ajax查询,并在response.responseText中获取XLSX文件。我无法找到一种下载方式。当我得到CSV文件作为响应时,它工作正常,我可以使用blob保存它。现在我得到的就是这个:
我的CSV正常工作,但现在不工作了:
Ext.Ajax.request({
url: "",
success: function (response) {
var blob = new Blob([response.responseText], { type: "text/csv;charset=utf-8;" });
if (navigator.msSaveBlob) { // IE 10+
navigator.msSaveBlob(blob, downDate + "Report.csv")
} else {
var link = document.createElement("a");
if (link.download !== undefined) { // feature detection
// Browsers that support HTML5 download attribute
var url = URL.createObjectURL(blob);
link.setAttribute("href", url);
link.setAttribute("download", downDate + "Report.csv");
link.style = "visibility:hidden";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
}
},
failure: function () { Ext.Msg.alert('Ajax Query Failure'); }
});
我将类型更改为仍然无法正确保存...
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8