Datatable的值为将数据从DataTable导出到Excel 2007中
斯大林 - 001和迈克尔 - 002。但产生练成我获得输出作为
在产生到Excel中的“0”并不coming.how解决这一类型scenerios的。
代码:
if (dt.Rows.Count > 0)
{
string filename = " ExportedData.xls";
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
DataGrid dgGrid = new DataGrid();
dgGrid.DataSource = dt;
dgGrid.DataBind();
dgGrid.RenderControl(hw);
Response.ContentType = "application/vnd.ms-excel";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename + "");
this.EnableViewState = false;
Response.Write(tw.ToString());
Response.End();
}
你的代码粘贴为** **文,而不是一个图像.. – 2013-03-01 16:41:33
好@ TimSchmelter,我将如何得到该文件? – gpa 2013-03-01 16:45:39
@SonerGönül但是那么SO不会以斜体Times New Roman格式编码! – 2013-03-01 16:46:01