标签:
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");
}
标签:
原文地址:http://www.cnblogs.com/wlzhang/p/4947737.html