title: How to export dynamic gridview data to excel
body: <p>I have created dynamic grid for report and kept an option as export to excel. I used html Render-Control to export but my problem is when i tried to export in excel, i am getting blank excel sheet. Any one can you please help me. Thanks in advance</p>
  
  <pre><code>Response.Clear();
          string date_only_for_excel = DateTime.Now.Date.ToString("dd/MM/yyyy");
          string FileName = "REPORT_" + date_only_for_excel + ".xls";
          Response.AppendHeader("Content-Disposition", "attachment; filename=" + FileName + "");
          Response.Charset = "";
          Response.Cache.SetCacheability(HttpCacheability.NoCache);
          Response.ContentType = "application/vnd.xls";
          System.IO.StringWriter stringWrite = new System.IO.StringWriter();
          System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
  
  
  
          htmlWrite.Write("&lt;table&gt;&lt;tr&gt;&lt;td colspan='24'&gt;&lt;/td&gt;&lt;/tr&gt;");
          htmlWrite.Write("&lt;table&gt;&lt;tr&gt;&lt;td colspan='24'&gt;&lt;/td&gt;&lt;/tr&gt;");
          //htmlWrite.Write("&lt;table&gt;&lt;tr&gt;&lt;td colspan='24' style='text-align:left;font-size:22;color:#f79646;margin-left:100px;'&gt;BOQ REPORT&lt;/td&gt;&lt;/tr&gt;");
          htmlWrite.Write("&lt;table&gt;&lt;tr&gt;&lt;td colspan='24'&gt;&lt;/td&gt;&lt;/tr&gt;");
          htmlWrite.Write("&lt;table&gt;&lt;tr&gt;&lt;td colspan='24'&gt;&lt;/td&gt;&lt;/tr&gt;");
          htmlWrite.Write("&lt;table&gt;&lt;tr&gt;&lt;td colspan='24'&gt;&lt;/td&gt;&lt;/tr&gt;");
          Div2.RenderControl(htmlWrite);
          Response.Write(stringWrite.ToString());
          Response.End();
  </code></pre>
  
  <p>I have created dynamic grid and added to this panel</p>
  
  <pre><code> &lt;asp:Panel ID="Export_Panel" runat="server"&gt;
                  &lt;/asp:Panel&gt;
  </code></pre>