c#将数据导出到excel中
2020-12-13 17:01
标签:http io ar os sp for 数据 on bs DataTable dt = new BLL.T_Expiry().GetAllList().Tables[0];//查询数据 string FileName = "T_Users.xls"; HttpResponse response = Page.Response; response.AppendHeader("Content-Disposition", "attachment;filename=" + FileName); foreach (DataColumn dc in dt.Columns) response.Write("\n"); foreach (DataRow dr in dt.Rows) response.Write("\n"); response.End(); c#将数据导出到excel中 标签:http io ar os sp for 数据 on bs 原文地址:http://www.cnblogs.com/apes-monkeys/p/4088894.html
Response.ContentType = "application/ms-excel";
response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
{
response.Write(dc.ColumnName + "\t");
}
{
for (int i = 0; i {
response.Write(dr[i].ToString() + "\t");
}
}