当前位置: 首页 > news >正文

uniapp APP下载流文件execl 并用WPS打开

使用plus.downloader.createDownload 方法将新建下载任务

HTML5+ API Reference

export default function plusDownload(config){if(!config){console.error("Argument should not be null");return;}const url=request.baseUrl+config.url;let token = uni.getStorageSync("token");let	header={//	'Content-Type':"application/octet-stream",'Authorization':"Bearer " + token//'Accept':'*/*'};config.header=config.header||{};Object.assign(header,config.header);let download= plus.downloader.createDownload(url,config,(d,s)=>config.complete(d,s,download));download.setRequestHeader('Authorization',"Bearer " + token);download.start();
}

封装方法

export function downloadInspectionResult(data) {uni.showLoading({title:'读取文件...',duration:10000});plusDownload({url:'/ny-iqc/incomingInspection/exportCoa?id='+data.id,method: 'POST',filename: '_downloads/'+data.fileName,header: { 'Content-Type': 'application/x-www-form-urlencoded' },data: data,complete: function (res,status,download) {uni.hideLoading();uni.openDocument({filePath: res.filename,fileType: 'xlsx',showMenu: true,success: () => {uni.showToast({title: '打开文档成功',icon: 'success',mask: true,});},fail: (error) => {console.log('error', error);},});},});
}

调用方法

downloadInspectionResult({
        id:id,
        fileName: fileName
 });

http://www.lryc.cn/news/237513.html

相关文章:

  • 【Python】 Python 操作PDF文档
  • vue3-响应式核心
  • 人工智能的广泛应用与影响
  • SAP创建权限对象、角色、并分配角色
  • [uni-app]记录APP端跳转页面自动滚动到底部的bug
  • 应用软件安全编程--23避免使用不安全的操作模式
  • 国产高云FPGA:纯verilog实现视频图像缩放,提供6套Gowin工程源码和技术支持
  • python操作windows窗口,python库pygetwindow使用详解
  • 手写消息队列(基于RabbitMQ)
  • kafka本地安装报错
  • 王者荣耀游戏
  • MobaXterm如何连接CentOS7的Linux虚拟机?Redis可视化客户端工具如何连接Linux版Redis?
  • python实现炫酷的屏幕保护程序
  • java学习part06数组
  • Java 的异常体系
  • V100 GPU服务器安装CUDA教程
  • 快速弄懂Python3.11中的新特性
  • 七,vi和vim
  • 湖科大计网:传输层
  • 设计模式(二)-创建者模式(3)-抽象工厂模式
  • [计算机网络]网络层概述
  • 猫12分类:使用yolov5训练检测模型
  • Kubernetes Dashboard部署ImagePullBackOff问题处理
  • 十四、Docker的基本操作
  • C#,数值计算——插值和外推,分段线性插值(Linear_interp)的计算方法与源程序
  • 详细讲解什么是单例模式
  • 在springBoot中同时使用mysql和MongoDB
  • 2023.11.19 hadoop之MapReduce
  • 力扣第841题 钥匙和房间 C++ DFS BFS 附Java代码
  • React 中 react-i18next 切换语言( 项目国际化 )