已临时调整为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' });
}
})
}