/// <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. C++、Java、Objective-C、Swift 二进制兼容测试

    鉴于目前动态库在iOS App中使用越来越广泛,二进制的兼容问题可能会成为一个令人头疼的问题.本文主要对比一下C++.Java.Objecive-C和Swift的二进制兼容问题. iOS端动态库使用情 ...

  2. non-fragile:oc2.0特性

    Runtime Versions and Platforms There are different versions of the Objective-C runtime on different ...

  3. LayIM.NetClient 组件开发记录

    前言 好久没写博客了.前阶段看了下Hangfire组件,后来对其代码比较感兴趣,当时不太了解他如何生成的页面和一些访问请求等.后来看了下源代码,发现原来是 OWIN 在搞怪.于是乎开始深入研究Hang ...

  4. ESlint 语法检测配置说明

    部分vue-cli脚手架创建的默认eslint规则: 代码末尾不能加分号 ; 代码中不能存在多行空行 tab键不能使用,必须换成两个空格 代码中不能存在声明了但未使用的变量 关闭eslint 这里只说 ...

  5. iOS 数据库sqlite3.0操作--超简单--看我就够啦

    iOS客户端数据存储的方式有很多,下面主要是介绍苹果自带的sqlite3.0的使用方法. 首先导入sqlite3.0的框架.然后导入头文件#import <sqlite3.h>就行了 下面 ...

  6. NOIP2018(更新中)

    \(Day_1T_1\) 铺设道路 (Link) 现在你有一个序列,每一个\(i\)有一个深度\(Deep[i]\),现在你可以选择任意的区间,将整个区间的\(Deep\)都减少\(1\).但前提是这 ...

  7. [转]Javascript 取小数点后面N位

    用Javascript取float型小数点后两位,例22.127456取成22.13,如何做? 1. 最笨的办法....... [我就怎么干的.........] }  2. 正则表达式效果不错 &l ...

  8. linux c 获取当前时间 毫秒级的 unix网络编程

    #include <time.h> #inlcude <sys/time.h> char *gf_time(void) /* get the time */{ struct t ...

  9. Faster Alternatives to glReadPixels and glTexImage2D in OpenGL ES

    In the development of Shou, I’ve been using GLSL with NEON to manipulate image rotation, scaling and ...

  10. C# 5.0中使用CallerMemberName、CallerFilePath和CallerLineNumber获取代码的调用方信息(转载)

    很多时候,我们需要在运行过程中记录一些调测的日志信息,如下所示: public void DoProcessing() { TraceMessage("DoProcessing()被XXX调 ...