將數據傳輸到ASP.NET中的Excel工作表網格視圖;如何解決這類問題 錯誤是將數據從gridview導出到ASP.NET中的Excel
Control 'ContentPlaceHolder1_gvdetails' of type 'GridView' must be placed inside a form tag with runat=server.
這是我的代碼:
Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", string.Format("attachment; filename={0}",
"Customers.xls"));
Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
gvdetails.AllowPaging = false; gvdetails.DataBind();
gvdetails.HeaderRow.Style.Add("background-color", "#FFFFFF");
gvdetails.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
什麼是您所遇到截至目前確切的問題? – pordi 2013-04-08 08:24:32
此代碼在excel表格中未顯示空白excel表單數據如何在excel表單中加載網格視圖數據幫助我 – 2013-04-08 09:12:06