我也用以上方法將數據導入EXCEL,但顯示的EXCEL工作表一片空白,請問為什麼?原碼如下:
Response.ContentType ="application/vnd.ms-excel";
//從Content-Type header中去除charset
Response.Charset = "";
// 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);
//DataGrid1.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();