HttpContext.Current.Response.AppendHeader( "Content-Disposition ", "attachment;filename=Excel.xls ");
HttpContext.Current.Response.Charset = "UTF-8 ";
HttpContext.Current.Response.ContentEncoding =System.Text.Encoding.Default;
HttpContext.Current.Response.ContentType = "application/ms-excel ";//image/JPEG;text/HTML;image/GIF;vnd.ms-excel/msword
ctl.Page.EnableViewState =false;
System.IO.StringWriter tw = new System.IO.StringWriter() ;
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter (tw);
ctl.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End(); 用这个看看
加这个试试?
public override void VerifyRenderingInServerForm(Control control)
{}
加这个试试??
public override void VerifyRenderingInServerForm(Control control)
{}
这句也有问题,只能用Response.AppendHeader方法加上字符集
直接写RESPONSE.charset="UTF-8 "也是整段代码不执行,点击linkbutton无反应
Response.Clear();
Response.Buffer = false;
Response.Charset = "GB2312";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + name);
Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");
Response.ContentType = "application/ms-excel";
Response.Write("<meta http-equiv=Content-Type content=\"text/html; charset=UTF-\">");
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
gv.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
这样呢???