收藏
回答

[BUG] writeFile 写入binary类型的excel文件wps打开提示文件已损坏

问题类型 API/组件名称 微信版本 基础库版本
Bug writeFile 8.0.70 3.6.6
已临时调整为base64格式解决
const excelBuffer = XLSX.write(tempworkbook, { bookType: 'xlsx', type: 'base64', cellStyles: true });
  fs.writeFile({
    filePath: excelfilepath,
    data: excelBuffer,
    encoding: 'base64',
    success(res) {
      //console.log(res)
      //wx.showToast({ title: '写入excel成功', icon: 'none' });
    },
    fail(err) {
      //console.log(err)
      //wx.showToast({ title: '写入失败:' + err.errMsg, icon: 'none' });
    }
之前一直用的binary,4月份开始使用openDocument无法正常打开,页面没有fail报错,但是跳转wps提示excel文件格式无法识别,可能文件已损坏,文件大小只有5B
openExcel(){
    wx.openDocument({
      filePath: filePath,
      fileType:'xlsx',
      showMenu:true,
      fail(err) {
        wx.showToast({ title: '预览文件失败'+err.errMsg, icon: 'error' });
      }
    })
  }
回答关注问题邀请回答
收藏

1 个回答

  • 智能回答 智能回答 本次回答由AI生成
    04-14
    有用
    回复
登录 后发表内容