asp.net中如何把动态生成的table中的数据导入EXCEL

2024-12-09 09:42:27
推荐回答(1个)
回答1:

HttpContext.Current.Response.ContentType = "application/octet-stream";
//通知浏览器下载文件而不是打开
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode("名单模版.xls", System.Text.Encoding.UTF8));
HttpContext.Current.Response.BinaryWrite(by);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();