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

C# 下载模板文件 Excel

后端代码

[HttpGet("DownloadExcel")]public async Task<dynamic> DownloadExcel(string tmplName){var _fileName = "导入表模板.xlsx";var filePath = @"Files\DownLoad\";var NewFile = Path.Combine(filePath, tmplName);var stream = new FileStream(NewFile, FileMode.Open);return new FileStreamResult(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");}

前端代码 vue 2.0

// 下载导入表模板downloadExcel() {Axios.get('/api/Excel/DownloadExcel', {params: {tmplName: 'Excel'},responseType: 'blob',}).then(res => {const link = document.createElement('a')// const blob = new Blob([res.data], { type: 'application/vnd.ms-excel' })const blob = new Blob([res.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' })link.style.display = 'none'link.href = URL.createObjectURL(blob)link.download = 'xxx入表模板.xlsx'document.body.appendChild(link)link.click()document.body.removeChild(link)}).catch(error => {console.log(error)})},

注意: 发布的WebAPI项目中有模板文件和文件夹

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

相关文章:

  • 如何做好sop流程图?sop流程图用什么软件做?
  • JAVA编程题-求矩阵螺旋值
  • Python--入门
  • STM32复习笔记(二):GPIO
  • POJ 3264 Balanced Lineup 线段树 / 平方分割
  • element-plus自动引入组件报错,例如collapse、loading
  • ChainForge:衡量Prompt性能和模型稳健性的GUI工具包
  • 队列--二叉树层序遍历
  • Ceph入门到精通-Linux内核网络参数优化小结
  • AWK语言第二版 2.6个人库 2.7小结
  • 8年经验之谈 —— Web ui自动化测试框架总结!
  • Kafka在企业级应用中的实践
  • 使用企业订货系统后的效果|软件定制开发|APP小程序搭建
  • STL关联式容器set,multiset,pair,map
  • MFC文本输出学习
  • Python 数据分析与挖掘(一)
  • 【问题证明】矩阵方程化为特征值方程求得的特征值为什么是全部特征值?不会丢解吗?
  • 虹科干货 | 不是吧,Redis Enterprise也能当向量数据库来用?
  • 汽车驾驶 - 四梁六柱是什么
  • CI522 13.56MHZ电动车NFC测试资料
  • 【微信小程序开发】一文学会使用CSS样式布局与美化
  • 漏刻有时物联网环境态势感知大数据(设备列表、动态折线图)
  • 【力扣】单调栈:901. 股票价格跨度
  • 4_使用预训练模型 微调训练CIFAR10
  • 机器学习笔记(一)
  • 学习在原地打转的原因与解决 如何步步为营 一日千里快速进步 考研工程计算 1万小时=416.666666667 天
  • 194、SpringBoot --- 下载和安装 Erlang 、 RabbitMQ
  • 机器学习7:pytorch的逻辑回归
  • Java应用程序中如何实现FTP功能 | 代码示例和教程
  • kotlin:list的for循环