ExtAspNet从DataTable里导出Excel
2021-07-11 01:06
标签:file for tostring tab send net osi csharp app ExtAspNet从DataTable里导出Excel 标签:file for tostring tab send net osi csharp app 原文地址:http://www.cnblogs.com/tlnshuju/p/7087333.html protected void btn_ToExcel_Click(object sender, EventArgs e)
{
Response.ClearContent();
Response.AddHeader("content-disposition", "attachment; filename=MyExcelFile.xls");
Response.ContentType = "application/excel";
Response.Write(GetDataTableHtml((DataTable)ViewState["tt"]));
Response.End();
}
private string GetDataTableHtml(DataTable dt)
{
StringBuilder sb = new StringBuilder();
sb.Append("
");
sb.Append("
");
return sb.ToString();
}");
foreach (DataColumn column in dt.Columns)
{
sb.AppendFormat(" ");
foreach (DataRow row in dt.Rows)
{
sb.Append("{0} ", column.Caption);
}
sb.Append("");
for (int i = 0; i {0}", html);
}
sb.Append(" ");
}
sb.Append("
上一篇:学习11 网页插入图片标签
下一篇:css中三种定位详细介绍
文章标题:ExtAspNet从DataTable里导出Excel
文章链接:http://soscw.com/index.php/essay/103481.html