C# 导出CSV

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

上一篇:C# tableGridView控件


下一篇:如何处理 api 重复提交,接口幂等性