封装Excls数据导出功能 返回一个下载链接地址
/// <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数据导出功能 返回一个下载链接地址的更多相关文章
- ThinkPHP 整合 PHPExcel ,数据导出功能实现,解决Invalid cell coordinate
PHPExcel想必大家都不陌生,是用来操作Office Excel 文档的一个PHP类库,它基于微软的OpenXML标准和PHP语言.可以使用它来读取.写入不同格式的电子表格 本次只做数据导出功能的 ...
- mssqlserver数据导出到另外一个数据库
mssqlserver数据导出到另外一个数据库 准备源数据库,找到想要导出的数据库,右键选择"任务"再选择"导出数据" 设置源数据库信息 3.设置目标数据库,导 ...
- 怎么找到苹果App Store的应用程序下载链接地址
http://jingyan.baidu.com/article/6dad5075f6fa79a123e36e85.html 怎么找到苹果App Store的应用程序下载链接地址 每个上传到苹果app ...
- ThinkPHP5使用PHPExcel实现数据导出功能
1.将PHPExcel类库文件夹放入extend目录下 2.导出功能实现 public function download(){ if(request()->isPost()){ $val = ...
- abp中文件下载,将内存数据导出到Excel并下载
1.数据导出为Excel的Stream using System; using System.Collections.Generic; using System.IO; using Abp.Colle ...
- ASP.NET MVC5 使用NPOI导出ExceL 返回浏览器下载
一,什么是NPOI 该项目是位于http://poi.apache.org/的POI Java项目的.NET版本.POI是一个开源项目,可以帮助您读取/写入xls,doc,ppt文件.它有着广泛的应用 ...
- Excel数据导出功能
HTML代码: <a id="aExportData" hidden><span>Export</span></a> <div ...
- jxl写入excel实现数据导出功能
@RequestMapping(params = "method=export", method = RequestMethod.GET) public void exportCo ...
- java web 读取数据库数据写入Excel返回浏览器下载
@RequestMapping(value = "/download", method = RequestMethod.GET) public void downstudents( ...
随机推荐
- xml-apis-ext.jar
xml-apis-ext.jar,hightcharts导出图片是解决乱码需要用到的一个包
- django 静态文件
django 1.8版本以上 django 静态文件配置. 小作之前, 一直觉得django的静态文件配置非常的麻烦. 1. 要设置url(r'^static/(?P<path>.*)&a ...
- 调整home和根分区大小
目标:将VolGroup-lv_home缩小到100G,并将剩余的空间添加给VolGroup-lv_root ============================================= ...
- 移动端 Touch 事件
在移动端页面开发时,常常会用到touch事件,比如左滑右滑的轮播等.常用的触摸事件有touchstart,touchmove,touchend. 每个事件包含下面三个用于跟踪虎摸的属性: touche ...
- 理解HTML DOM
DOM(Document Object Model)全称文档对象模型.DOM其实是JavaScript操作网页的一套API接口,定义了访问和操作HTML文档的标准.定义了所有HTML元素的对象和属性, ...
- Charles Proxy v4.1.3 Mac、Win64、Win32破解版
http://charles.iiilab.com/ 1. 下载Charles Proxy 4.1.3版本,百度云盘下载 或 去官网下载 2. 安装后先打开Charles一次(Windows版可以忽略 ...
- 什么是Apache Isis
这个页面展示了一个现代的 Apache Isis 应用程序的外观. 下边是Isis 插件里的 todoapp 示例 (非 ASF)截图,你可以随意使用. 界面里对应的领域类可以在这里找到. 这个 to ...
- java三大特性(封装、继承、多态)
oop(面向对象程序设计)具有三大特性:封装.继承.多态 一.封装 封装就是讲类的信息隐藏在类的内部,不允许外部程序直接访问,而是通过该类的实现隐藏信息的操作和访问. 实现封装 1.需要修改属性的访问 ...
- 【luogu P4017 最大食物链计数】 题解
题目链接:https://www.luogu.org/problemnew/show/P4017 DAG + DP #include <queue> #include <cstdio ...
- android中OpenMax的实现【3】OMX中主要成员
原文 http://blog.csdn.net/tx3344/article/details/8117908 通过上文知道了,每个AwesomePlayer 只有一个OMX服务的入口,但是Awesom ...