收藏
回答

openDocument无法打开xls文件,其他文件类型可以打开

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug openDocument 客户端 6.7.3 2.2

- 当前 Bug 的表现(可附上截图)


- 预期表现

保存本地,是可以打开。但是无法用openDocument,移动端也是这种情况

- 复现路径


- 提供一个最简复现 Demo

/**

* 下载文件并预览

*/

function downloadFile(url) {

wx.downloadFile({

url: url,

success: function(res) {

var filePath = res.tempFilePath;

console.log(filePath);

wx.openDocument({

filePath: filePath,

fileType:'xls',

success: function(res) {

console.log("打开文件成功");

},

fail: function(res) {

console.log(res);

},

complete: function(res) {

console.log(res);

}

})

},

fail: function(res) {

console.log('文件下载失败');

},

complete: function(res) {},

})

}



最后一次编辑于  2018-12-08
回答关注问题邀请回答
收藏

4 个回答

  • 禾店短剧系统
    禾店短剧系统
    2021-06-11

    请先转成.doc文件后再下载

    2021-06-11
    有用 1
    回复
  • 灵芝
    灵芝
    2018-12-10

    麻烦提供能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

    2018-12-10
    有用 1
    回复 7
    查看更多(2)
  • 张钢锋🐛
    张钢锋🐛
    2018-12-08

    是走success方法的。按道理应该是成功的。

    2018-12-08
    有用 1
    回复 1
    • 张钢锋🐛
      张钢锋🐛
      2018-12-11

      这个问题有很多原因。当我不加上AppId在PC的时候,可以打开xls,加了就无法打开。最后的解决方案就是转成xlsx格式的。在真机上或PC端都可以兼容。

      2018-12-11
      1
      回复
  • 韬々
    韬々
    2018-12-10

    看起来像是路径的问题。





    试试看去掉调用openDocument时传入的fileType字段?

    2018-12-10
    有用
    回复 1
    • 张钢锋🐛
      张钢锋🐛
      2018-12-11

      还是打不开。Excel后缀名太长。不支持打开。我的系统是XP系统

      2018-12-11
      回复
登录 后发表内容