title: Export Html Tables to Multiple Excel Sheet using C#
body: <p>How to export multiple tables to multiple excel sheet using c#? Below code is working but only for 1 html table.    </p>
  
  <pre><code>    Response.ContentType = "application/x-msexcel";
      Response.AddHeader("Content-Disposition", "attachment; filename=ExcelFile.xls");
      Response.ContentEncoding = Encoding.UTF8;
      StringWriter tw = new StringWriter();
      HtmlTextWriter hw = new HtmlTextWriter(tw);
      tbl.RenderControl(hw);
      Response.Write(tw.ToString());
      Response.End();
  </code></pre>
  
  <p>Below are tables in *.aspx page. And i want to both tables in one excel with multiple sheet.</p>
  
  <p>for Example : Table 1 is in worksheet 1 
   table 2 is in worksheet 2</p>
  
  <pre><code>  &lt;table id="tbl" border="1" runat="server" &gt;
                  &lt;tr&gt;
                      &lt;td&gt;Product&lt;/td&gt;
                      &lt;td&gt;Price&lt;/td&gt;
                      &lt;td&gt;Available&lt;/td&gt;
                      &lt;td&gt;Count&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Bred&lt;/td&gt;
                      &lt;td&gt;1
                      &lt;/td&gt;
                      &lt;td&gt;2
                      &lt;/td&gt;
                      &lt;td&gt;3
                      &lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Butter&lt;/td&gt;
                      &lt;td&gt;4
                      &lt;/td&gt;
                      &lt;td&gt;5
                      &lt;/td&gt;
                      &lt;td&gt;6
                      &lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/table&gt;
  
       &lt;table id="tbl2" border="1" runat="server" &gt;
                  &lt;tr&gt;
                      &lt;td&gt;KD&lt;/td&gt;
                      &lt;td&gt;Dabhi&lt;/td&gt;
                      &lt;td&gt;Qnil&lt;/td&gt;
                      &lt;td&gt;Dabhi&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Bred&lt;/td&gt;
                      &lt;td&gt;1
                      &lt;/td&gt;
                      &lt;td&gt;2
                      &lt;/td&gt;
                      &lt;td&gt;3
                      &lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Butter&lt;/td&gt;
                      &lt;td&gt;4
                      &lt;/td&gt;
                      &lt;td&gt;5
                      &lt;/td&gt;
                      &lt;td&gt;6
                      &lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/table&gt;
  
  
       &lt;asp:Button runat="server" ID="ExportToExcelButton" OnClick="ExportToExcelButton_Click"
          Text="Export To Excel" /&gt;
  </code></pre>