已解决
uniapp小程序下载导出excel
来自网友在路上 158858提问 提问时间:2023-09-23 12:52:59阅读次数: 58
最佳答案 问答题库588位专家为你答疑解惑
uniapp小程序下载excel
<button @click="exportFilledFun">导出excel</button>
exportFilledFun() {uni.request({url: `https://test.yunsign.net/file.php`,method: 'GET',responseType: 'arraybuffer',success: (res) => {const fileManagerObj = uni.getFileSystemManager() // 获取全局的文件管理器console.log(fileManagerObj);// 文件存储到本地的路径const filePath = `${wx.env.USER_DATA_PATH}/${new Date().getTime()}.xlsx` fileManagerObj.writeFile({data: res.data, // 拿到的arraybuffer数据filePath: filePath,encoding: 'binary',success: (res) => {console.log(res) // 成功了的话这里会打印 writeFile:okthis.viewDoc(filePath)}})},fail: (err) => {console.log(err)}})
},
// 打开文件
viewDoc(filePath) {uni.openDocument({// 直接打开filePath: filePath, // 这里填上面写入本地的文件路径fileType: 'xlsx',showMenu: true, // 右上角是否有可以转发分享的功能,配不配随意success: (res) => {console.log('打开文档成功')}})
},
查看全文
99%的人还看了
相似问题
猜你感兴趣
版权申明
本文"uniapp小程序下载导出excel":http://eshow365.cn/6-12093-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!