用Response导出excel表,有图片和标题,datagrid。除了图片都能正常导出显示。图片就变成叉叉。
代码如下:
Response.Clear();
Response.Buffer= true;
Response.Charset="GB2312";
Response.AppendHeader("Content-Disposition","attachment;filename=FileFlow.xls");
Response.ContentEncoding=System.Text.Encoding.GetEncoding("GB2312");
Response.ContentType = "application/vnd.ms-excel";
// 定义一个输入流
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
this.ClearControls(DataGrid1);
this.header.RenderControl(oHtmlTextWriter);
this.DataGrid1.RenderControl(oHtmlTextWriter);
this.foot.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();
代码如下:
Response.Clear();
Response.Buffer= true;
Response.Charset="GB2312";
Response.AppendHeader("Content-Disposition","attachment;filename=FileFlow.xls");
Response.ContentEncoding=System.Text.Encoding.GetEncoding("GB2312");
Response.ContentType = "application/vnd.ms-excel";
// 定义一个输入流
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
this.ClearControls(DataGrid1);
this.header.RenderControl(oHtmlTextWriter);
this.DataGrid1.RenderControl(oHtmlTextWriter);
this.foot.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货