出于对数据安全的考虑,查询到的表格数据是以base64数据形式返回给到前端,需要前端自行解析处理。如果直接返回www.xxx.xx/aa.xlsx 这种形式就会容易很多。
案例: 如下body字段的数据,就是表格的数据,对其进行展示。
![786bb62a221bcc4eaeb407665facf43e.png](https://i-blog.csdnimg.cn/blog_migrate/4022fe06716401cd85b615dbbdf41538.jpeg)
base64形式的文件下载处理
微信小程序处理
- 利用wx.base64ToArrayBuffer(data) 将base64 数据转成ArrayBuffer
- getFileSystemManager 把数据写入到本地(writeFile)
- 利用wx.openDocument 打开生成的文件即可。
const fileReg = /.pdf$|.xlsx$|.doc$|.docx$|.xls$/i; filename = filename.trim(); if (!fileReg.test(filename)) { toast("warn 需要设置文件格式,默认打开xlsx"); filename = `${filename}.xlsx`; } const _fsm = wx.getFileSystemManager(); _fsm && _fsm.writeFile({ filePath: `${wx.env.USER_DATA_