我是靠谱客的博主 魁梧睫毛,这篇文章主要介绍后台生成Excel,前台下载,现在分享给大家,希望可以做个参考。

前端:
1.导入ajax.js

import request from '@/plugin/ajax.js'

2.接口使用

有api文件
const TestExcelDonation = function (params) {//导出Excel
  return request({
    url: `${prefixerForProxy}/Test/QueryToExcel`,
    method: 'get',
      headers: {
        'Content-Type': 'multipart/form-data;charset=UTF-8'
      },
      responseType: 'blob', //二进制流
    params
  })
}
文件下载:
api.TestExcelDonation().then(res=>{
	const blob = new Blob([res.data]);
	saveAs(blob, "Test.xls");
})

后端:

  public ActionResult QueryToExcel(QueryDonationModel para)
{
			//路径
            var path = _test.QueryToExcel(para);
            return File(new FileStream(path, FileMode.Open), "application/octet-stream", "资金捐赠台账.xls");
}

最后

以上就是魁梧睫毛最近收集整理的关于后台生成Excel,前台下载的全部内容,更多相关后台生成Excel内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(65)

评论列表共有 0 条评论

立即
投稿
返回
顶部