码迷,mamicode.com
首页 > Web开发 > 详细

mvc 导出execl

时间:2015-11-08 19:13:16      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:

mvc导出execl 必须是get方法才可以  也不能使用ajax 

function ComplaintsExport() {
var serial = $("form").serialize();
window.location.href = "/BidComplaints/Complaints/ComplaintsExport?" + serial;
};

 

[HttpGet]
[Description("导出")]
public FileResult ComplainExport(Bid_Complaints model)
{
model.ComplaintsType = (int)ComplainEnum.ComplaintsType.投诉;
var dt = ComplainManage.GetdtBymodelNopage(model);
string[] strFields = { "ComplaintsID", "zComplaintsObjType", "ComplaintsMessage", "zComplaintsime", "zDisposeStatus", "DisposeMessage", "DisposeUserID", "zDisposeTime" };
string[] strFieldsName = { "投诉编号", "投诉类型", "投诉内容", "投诉时间", "处理状态", "处理内容", "处理用户编号", "处理时间" };

MemoryStream ms = new MemoryStream();
ms = ExcelHelper.WriteStream(dt, "投诉信息", "投诉信息", strFields, strFieldsName);

ms.Seek(0, SeekOrigin.Begin);
return File(ms, "application/vnd.ms-excel", "投诉信息" + DateTime.Now.ToString("D") + "-" + DateTime.Now.ToString("HH时mm分ss秒") + ".xls");
}

mvc 导出execl

标签:

原文地址:http://www.cnblogs.com/wlzhang/p/4947737.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!