/// <summary>
/// 获取本地存储地址
/// </summary>
/// <param name="dt"></param>
/// <param name="prefix">前缀类别</param>
/// <returns></returns>
public string GetDwonLoadlPath(DataTable dt, string prefix)
{
string filename = System.Configuration.ConfigurationManager.AppSettings[prefix].ToString() + Guid.NewGuid() + ".xlsx";
string filePath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + "\\File\\Download\\" + filename;
string returnpath = System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath + "/File/Download/" + filename;
ExcelHelper.DataTableToExcel(dt, filePath);
return System.Configuration.ConfigurationManager.AppSettings["DomainName"] + returnpath;
}
 public class DrugParamsHelper
{
private static volatile DrugParamsHelper drugParamsHelper = null;
private static object syncRoot = new Object();
public DrugParamsHelper()
{ }
/// <summary>
/// 初始化注册
/// </summary>
public static DrugParamsHelper Instance
{
get
{
if (drugParamsHelper == null)
{
lock (syncRoot)
{
if (drugParamsHelper == null)
{
if (true)
{
}
drugParamsHelper = new DrugParamsHelper();
}
}
}
return drugParamsHelper;
}
}
/// <summary>
/// 获取本地存储地址
/// </summary>
/// <param name="dt"></param>
/// <param name="prefix">前缀类别</param>
/// <returns></returns>
public string GetDwonLoadlPath(DataTable dt, string prefix)
{
string filename = System.Configuration.ConfigurationManager.AppSettings[prefix].ToString() + Guid.NewGuid() + ".xlsx";
string filePath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + "\\File\\Download\\" + filename;
string returnpath = System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath + "/File/Download/" + filename;
ExcelHelper.DataTableToExcel(dt, filePath);
return System.Configuration.ConfigurationManager.AppSettings["DomainName"] + returnpath;
}}

调用示例

  //转换列名称成中文名
Dictionary<string, string> RenameColumDic = new Dictionary<string, string>();
queryParams.colCollection.ForEach(f =>
{
RenameColumDic.Add(f.FieldName, f.DisplayName);
});
//将对象转成datatble
DataTable dataTable = ListTranDataTableHelper.ToDataTable<ClinicalRegistrationCach>(list, RenameColumDic, queryParams.colCollection.Select(c => c.FieldName).ToArray());
return new Response<string>(DrugParamsHelper.Instance.GetDwonLoadlPath(dataTable, "CDEExclsName"));

封装Excls数据导出功能 返回一个下载链接地址的更多相关文章

  1. ThinkPHP 整合 PHPExcel ,数据导出功能实现,解决Invalid cell coordinate

    PHPExcel想必大家都不陌生,是用来操作Office Excel 文档的一个PHP类库,它基于微软的OpenXML标准和PHP语言.可以使用它来读取.写入不同格式的电子表格 本次只做数据导出功能的 ...

  2. mssqlserver数据导出到另外一个数据库

    mssqlserver数据导出到另外一个数据库 准备源数据库,找到想要导出的数据库,右键选择"任务"再选择"导出数据" 设置源数据库信息 3.设置目标数据库,导 ...

  3. 怎么找到苹果App Store的应用程序下载链接地址

    http://jingyan.baidu.com/article/6dad5075f6fa79a123e36e85.html 怎么找到苹果App Store的应用程序下载链接地址 每个上传到苹果app ...

  4. ThinkPHP5使用PHPExcel实现数据导出功能

    1.将PHPExcel类库文件夹放入extend目录下 2.导出功能实现 public function download(){ if(request()->isPost()){ $val = ...

  5. abp中文件下载,将内存数据导出到Excel并下载

    1.数据导出为Excel的Stream using System; using System.Collections.Generic; using System.IO; using Abp.Colle ...

  6. ASP.NET MVC5 使用NPOI导出ExceL 返回浏览器下载

    一,什么是NPOI 该项目是位于http://poi.apache.org/的POI Java项目的.NET版本.POI是一个开源项目,可以帮助您读取/写入xls,doc,ppt文件.它有着广泛的应用 ...

  7. Excel数据导出功能

    HTML代码: <a id="aExportData" hidden><span>Export</span></a> <div ...

  8. jxl写入excel实现数据导出功能

    @RequestMapping(params = "method=export", method = RequestMethod.GET) public void exportCo ...

  9. java web 读取数据库数据写入Excel返回浏览器下载

    @RequestMapping(value = "/download", method = RequestMethod.GET) public void downstudents( ...

随机推荐

  1. miniui dataGrid detail grid

    <div >      <div id="vkhGrjx_grid" class="mini-datagrid" style="wi ...

  2. 使用 Open Live Writer 创建我的第一个博文

    希望能在此记录我的技术开发过程. 请记住我的博客首页为:https://www.cnblogs.com/unrulife/ 期待在博客园遇到志同道合的朋友! 希望在博客园开启技术生涯的新篇章!

  3. 快速了解jquery

    jQuery的基本设计思想和主要用法,就是"选择某个网页元素,然后对其进行某种操作".这是它区别于其他Javascript库的根本特点. 所以jquery的基础语法是: $(sel ...

  4. building for production...Killed

    npm run build报错 building for production...Killed 原理 按照他人的说法是,服务器内存不够用了,这样就给他配置一个单独的内存出来就解决了 解决方法 sud ...

  5. Many-to-many relationships in EF Core 2.0 – Part 2: Hiding as IEnumerable

    In the previous post we looked at how many-to-many relationships can be mapped using a join entity. ...

  6. 一文读懂类加载机制--ClassLoader

    一.什么是ClassLoader? 大家都知道,当我们写好一个Java程序之后,不是管是CS还是BS应用,都是由若干个.class文件组织而成的一个完整的Java应用程序,当程序在运行时,即会调用该程 ...

  7. oracle表空间的创建+权限分配

    /*分为四步 */ /*第1步:创建临时表空间 */ create temporary tablespace user_temp tempfile 'D:\oracle\oradata\Oracle9 ...

  8. Spring知识点小结(三)

    一.aop的简介 aop:面向切面编程    aop是一种思想,面向切面编程思想,Spring内部提供了组件对aop进行实现    aop是在运行期间使用动态代理技术实现的思想    aop是oop延 ...

  9. 持续集成(CI – Continuous Integration)

    持续集成(CI – Continuous Integration) 在传统的软件开发中,整合过程通常在每个人完成工作之后.在项目结束阶段进行.整合过程通常需要数周乃至数月的时间,可能会非常痛苦.持续集 ...

  10. 数据库与python的连接

    db=web.database( dbn="mysql", host="localhost", port=3306, user="root" ...