请问uniapp里, 在APP的环境中后端返回blob流, 如何下载成为Excel?或者可以手动生成Excel,用数据填充进去
uni.downloadFile({
url: '/equipment/export',
method: 'POST',
header: {
Authorization: `Bearer ${token}`,
},
success: (res) => {
console.log('res: ================ ', res)
if (res.statusCode === 200) {
uni.saveFile({
tempFilePath: res.tempFilePath,
success: (e) => {
uni.openDocument({
filePath: e.savedFilePath,
fail: (e) => {
console.log('e: ======================= ', e)
uni.showToast({
title: `打开失败${e}`,
})
},
})
},
fail: (e) => {
uni.showToast({
title: `保存失败${e}`,
})
},
})
}
},
fail: (e) => {
uni.showToast({
title: `文件下载失败${e}`,
icon: 'none',
})
},
})
因为是post,还需要传递搜索条件,这个尝试了好像不行
后续有找到解决方法,再此记录,希望可以帮到有相同问题的同志
1.请求方式
2.后端返回数据Blob格式,先转为base64
3.有查到其余下载方式,我的场景为下载excel文件,确认可用,原文如下
https://blog.csdn.net/qq285679784/article/details/126838827
4.方法如下:
5.使用方式
6.补充,因为我要转换请求参数--tansParams方法()