导出execl
string filepath = Utils.GetMapPath("/upload/excel/");
filepath = filepath + fileName + ".xls";
string tempFilePath = Utils.GetMapPath("/ExcelTemplate/export_comment_excel.xlsx");
DataSet ds = new BLL.Comment().GetList(, strWhere, "addtime desc");
DataTable exportDT = new DataTable();
exportDT.Columns.Add("姓名", typeof(string));
exportDT.Columns.Add("评价等级(星星数)", typeof(int));
exportDT.Columns.Add("评价内容", typeof(string));
exportDT.Columns.Add("评价时间", typeof(string));
exportDT.Columns.Add("状态", typeof(string));
exportDT.Columns.Add("原因", typeof(string));
if (ds != null && ds.Tables[].Rows.Count > )
{
for (int i = ; i < ds.Tables[].Rows.Count; i++)
{
DataRow dr = exportDT.NewRow();
dr["姓名"] = ds.Tables[].Rows[i]["Name"].ToString();
dr["评价等级(星星数)"] = ds.Tables[].Rows[i]["level"].ToString();
dr["评价内容"] = ds.Tables[].Rows[i]["content"].ToString();
dr["评价时间"] = ds.Tables[].Rows[i]["addtime"].ToString();
dr["状态"] = GetStatus(ds.Tables[].Rows[i]["status"].ToString());
dr["原因"] = ds.Tables[].Rows[i]["reason"].ToString();
exportDT.Rows.Add(dr);
}
}
Common.ExcelToData.ExportExcel(tempFilePath, filepath, exportDT, "评论信息");
GC.Collect();//行销毁
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "application/ms-excel";
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName + "(" + DateTime.Now.ToString("yyMMddHHmm") + ").xls");
HttpContext.Current.Response.WriteFile(filepath);
HttpContext.Current.Response.Flush();
File.Delete(filepath);
HttpContext.Current.Response.End();
导出execl的更多相关文章
- 当用GridView导出Execl的时候,会发生只能在执行 Render() 的过程中调用 RegisterForEventValidation的错误
当用GridView导出Execl的时候,会发生只能在执行 Render() 的过程中调用 RegisterForEventValidation的错误提示. 有两种方法可以解决以上问题: 1.修改we ...
- asp.net中导出Execl的方法
一.asp.net中导出Execl的方法: 在 asp.net中导出Execl有两种方法,一种是将导出的文件存放在服务器某个文件夹下面,然后将文件地址 输出在浏览器上:一种是将文件直接将文件输出流写给 ...
- js导出execl兼容ie Chrome Firefox各种主流浏览器(js export execl)
第一种导出table布局的表格 <html> <head> <meta charset="utf-8"> <script type=&qu ...
- NPIO 导出Execl
步骤1:导入NOIO.dll (我导入压缩包中的4.0)
- mvc 导出execl
mvc导出execl 必须是get方法才可以 也不能使用ajax function ComplaintsExport() { var serial = $("form").ser ...
- POI导出Execl文件,使JAVA虚拟机OOM
由于在项目中使用POI导出execl,导致JAVA虚拟机OOM,采用以下方式解决问题: 原先方式: g_wb = new XSSFWorkbook(sourceFile.getInputStream( ...
- C# NPOI 导出Execl 工具类
NPOI 导出Execl 自己单独工具类 详见代码 using System; using System.Collections.Generic; using System.Linq; using S ...
- MVC 导出Execl 的总结几种方式 (四)
这种方式我个人还是比较喜欢的,使用部分视图的方式,导出Execl 这样在编辑样式上也是很方便的 第一步: 编辑导出视图页 @using H5UpdateImage.Models; @{ Layout ...
- MVC 导出Execl 的总结几种方式 (二)
接着上面的来,继续导出Execl 的功能 使用FileResult 方式直接可以生产Execl ,这样我们将会写大量处理后台的代码,个人感觉不好,只是展示出来,提供参考 第一步:编辑控制器 publi ...
- MVC 导出Execl 的总结几种方式 (一)
在ASP.NET 中导出Execl 表格有很多方式,有利有弊,就是看自己怎么使用了:下面就是自己总结了几种导出Execl 方式的,仅供参考. 导出Execl 的原理都是一样的,其实都是将数据整合成ta ...
随机推荐
- windows索引服务
windows索引服务是windows操作系统提供的桌面搜索引擎,通过预先创建索引来提高对硬盘上文件内容的搜索速度.以windows服务程序的方式运行. 一.工作方式 1.对指定路径下的文件创 ...
- pytorch深度学习神经网络实现手写字体识别
利用平pytorch搭建简单的神经网络实现minist手写字体的识别,采用三层线性函数迭代运算,使得其具备一定的非线性转化与运算能力,其数学原理如下: 其具体实现代码如下所示:import torch ...
- HBase查询速度慢原因排查
问题:通过HBase访问服务在HBase中查询 ASSET_NORMAL 表速度很慢 如下,查询一条数据需要2.970s时间: 如下,统计总条数需要14.675s时间: HBase访问服务部署了3个节 ...
- @@trancount什么意思(重要)
@@trancount什么意思 https://www.cnblogs.com/monian/archive/2012/08/24/2654392.html 在处理事务的时候,一般都用RollBack ...
- Linux CentOS7 VMware 特殊权限set_uid、特殊权限set_gid、特殊权限stick_bit、软链接文件、硬连接文件
一.特殊权限set_uid root用户本身拥有对/etc/passwd的写权限,无可厚非:那普通用户呢,这里就用到了setuid,setuid的作用是“让执行该命令的用户以该命令拥有者的权限去执行” ...
- 如何确定Redis集群中各个节点的主从关系
1.首先通过命令(以192.168.203.141为例,-c代表集群的意思) ./redis-cli -h 192.168.203.141 -p 8001 -c 2.然后在输入 cluster no ...
- luogu P2762 太空飞行计划问题
好像是最大权闭合图,也就是最大流最小割啦,找出最大流的路径输出,这题如何建模呢,一样的先设源点和汇点,源点向每个计划连capacity为赞助数的边,每个计划连相应装置capacity为无穷的边,每个装 ...
- [Verilog] indexed part-select +:
That syntax is called an indexed part-select. The first term is the bit offset and the second term ...
- mysqlworkbench导入sql文件
直接给上神秘地址怕自己以后忘记:https://blog.csdn.net/u010801439/article/details/78762387
- hdu 2222 Keywords Search 模板题
Keywords Search Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others ...