using (MemoryStream file = db.ExportExcel(model)) { context.Response.ContentType = "application/vnd.ms-excel"; context.Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", "历史告警数据.xls")); context.Response.Clear(); file.WriteTo(context.Response.OutputStream); context.Response.End(); }