当前位置:   article > 正文

uni-app 打开Excel文档_uniapp 读取excel

uniapp 读取excel
  1. <template>
  2. <view>
  3. <button @click="uniLookFile">打开文档</button>
  4. </view>
  5. </template>
  6. function uniLookFile() {
  7. uni.downloadFile({
  8. url: 'http://localhost:8080/excel/getExcel.xlsx',
  9. success: ({ tempFilePath }) => {
  10. console.log('tempFilePath', tempFilePath);
  11. uni.saveFile({
  12. tempFilePath: tempFilePath,
  13. success: ({ savedFilePath }) => {
  14. uni.showModal({
  15. title: '提示',
  16. content: '文档已保存',
  17. cancelText: '我知道了',
  18. confirmText: '打开文档',
  19. success: function (res) {
  20. if (res.confirm) {
  21. uni.openDocument({
  22. filePath: savedFilePath,
  23. fileType: 'xlsx',
  24. showMenu: true,
  25. success: () => {
  26. uni.showToast({
  27. title: '打开文档成功',
  28. icon: 'success',
  29. mask: true,
  30. });
  31. },
  32. fail: (error) => {
  33. console.log('error', error);
  34. },
  35. });
  36. } else if (res.cancel) {
  37. console.log('用户点击取消');
  38. }
  39. },
  40. });
  41. },
  42. fail: (error) => {
  43. console.log('error', error);
  44. },
  45. });
  46. },
  47. fail: (error) => {
  48. console.log('error', error);
  49. },
  50. });
  51. } console.error('下载文件时出错:', error);
  52. }
  53. }

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号