这种方式我个人还是比较喜欢的,使用部分视图的方式,导出Execl 这样在编辑样式上也是很方便的

第一步: 编辑导出视图页

@using H5UpdateImage.Models;
@{
Layout = null;
Response.AddHeader("Content-disposition", "attachment;filename=Order.xls");
} @model List<Order>
<!DOCTYPE html> <html>
<head>
<meta name="viewport" content="width=device-width" />
<title>ExeclIndex</title>
<style type="text/css">
.ltable th {
padding: 8px ;
color: #;
font-size: 12px;
font-weight: ;
background: #f3f3f3;
border-bottom: 1px solid #E1E1E1;
line-height: .5em;
} .ltable th, .ltable td {
border: 1px solid #e1e1e1;
text-align: center;
} .ltable th {
padding: 8px ;
color: #;
font-size: 12px;
font-weight: ;
background: #f3f3f3;
border-bottom: 1px solid #E1E1E1;
line-height: .5em;
}
</style> </head>
<body>
<table class="ltable">
<thead>
<tr>
<th> 订单编号</th>
<th>订单来源</th>
<th>会员姓名</th> </tr>
</thead>
<tbody class="ltbody">
@foreach (var item in Model)
{
<tr>
<td>@item.Id</td>
<td>@item.Name</td>
<td>@item.CreateTime</td>
</tr>
}
</tbody>
</table>
</body>
</html>

第二步: 控制代码

  /// <summary>
/// MVC 内置视图导出Execl
/// </summary>
/// <returns></returns>
public ActionResult ExeclIndex()
{
var list = GetList(); return View(list);
}

第三步: 触发导出 代码

 <a id="btnExport" href="javascript:ExportData();void(0);">导出</a>

js代码
function ExportData() { window.open('@Url.Action("ExeclIndex")');
}

最新文章

  1. python学习之路 第五天
  2. tomcat7下对HTTPS的部署配置
  3. Cesium应用篇:3控件(6) FullScreen/ VR / Home
  4. js获取当前对象的颜色判断改变颜色
  5. iOS开发 点击某处横屏竖屏切换
  6. geohash基本原理
  7. python求职之路
  8. Android 中调试手段 打印函数调用栈信息
  9. ResultSet的getInt(),getString()方法
  10. 值类型的Constructor
  11. c语言编译预处理和条件编译执行过程的理解
  12. Ajax简单实现文件异步上传的多种方法
  13. tcp dump 截取http
  14. ecshop首页调用指定商品分类下的商品品牌列表
  15. django csrf_token生成
  16. python study
  17. 【nodejs】nodejs 的linux安装(转)
  18. linux下安装python3
  19. java foreach遍历的前提条件
  20. 03_OGNL

热门文章

  1. 813. Largest Sum of Averages
  2. Educational Codeforces Round 34 (Rated for Div. 2) C. Boxes Packing
  3. ionic的基础学习(第一篇)
  4. jQuery 阻止冒泡和默认事件
  5. h5 端图片上传
  6. 第5章—构建Spring Web应用程序—关于spring中的validate注解后台校验的解析
  7. 【数组】Remove Duplicates from Sorted Array II
  8. 09 - JavaSE之线程
  9. 解决ssh登陆超时方案
  10. 使用epublib解析epub文件(章节内容、书籍菜单)