记录uniapp使用拉取excel表数据下载
uniapp使用拉取excel表数据下载
uni.request({
url: ‘’,
data: {
pavilionName: ‘’,
creatTime: ‘’,
},
method: “POST”,
header: header,
responseType: ‘arraybuffer’,
success: res => {
console.log(res)
if (res.statusCode == 200) {
if (res.data.code === “200” || res.data.code === “” || res.data.code ===
undefined) {
const blob = new Blob([res.data], {
type: ‘application/vnd.openxmlformats- officedocument.spreadsheetml.sheet’,
});
const url = window.URL.createObjectURL(blob)
const a = document.createElement(‘a’);
a.href = url;
a.download = ‘统计报表’;
a.click();
window.URL.revokeObjectURL(url);
}
}
},
})