>>其他页面无响应??is the browser dead?HOW TO: Export Data in a DataGrid on an ASP . NET WebForm to Microsoft Excel
http://support.microsoft.com/default.aspx?scid=kb;en-us;317719
http://support.microsoft.com/default.aspx?scid=kb;en-us;317719
其中contents是你左边frame的name,menu.aspx是放在frame里的页面
Response.AddHeader("Content-Disposition",
"attachment;filename=export.xls");
Response.ContentType="application/vnd.ms-excel";
Response.Charset ="utf-8";
this.EnableViewState =false;
System.IO.StringWriter tw=new
System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw=new
System.Web.UI.HtmlTextWriter(tw);
DataGrid1.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();
其中datagrid1中随便绑定点数据就可以,希望有兴趣的高手试试,如能解决,万分感谢!
{
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();
}
rabbitwy(流浪小兔),您好!后面写什么response.write()都没有反应了
---------------------------------------------------------------
那就把那句话放到Response.Flush()前面,不过我也没试过,我以前好像没这问题,产生EXCEL文件后昨天的菜单依然有效,代码在上面