首页 > Windows开发 > 详细

C# 导出CSV

时间:2020-04-21 18:51:49      阅读:89      评论:0      收藏:0      [点我收藏+]
Response.ClearContent();
Response.AddHeader("content-disposition", "attachment; filename=" + DateTime.Now.ToString("yyyy-MM-dd") + ".csv");
Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312"); Response.ContentType = "application/excel"; var sb = new StringBuilder(); sb.Append("姓名,工号,性别,部门\r\n"); foreach (var item in query) { sb.Append("\"" + item.Name + "\"" + ","); sb.Append("\"" + item.Code + "\"" + ","); sb.Append("\"" + item.Sex + "\"" + ","); sb.Append("\"" + item.deptName + "\"" + ","); } Response.Write(sb.ToString()); Response.End();

C# 导出CSV

原文:https://www.cnblogs.com/xybs/p/12747061.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!