title: Create excel file with two sheets in the same book - C#
body: <p>In my application, I have a method that return a excel file with one sheet. It works fine, but now I need to create another sheet and add it, and I dont figure out how. Here's my code:</p>
  
  <pre><code>    StringBuilder sb = new StringBuilder();
      string sFileName = "lottery" + Sorteio.Data.Date.ToShortDateString() + ".xls";
  
      sb.Append("&lt;x:ExcelWorkBook&gt;");
      sb.Append("&lt;x:ExcelWorkSheet&gt;");
      sb.Append("&lt;table style='1px solid black; font-size:12px;'&gt;");
  
      //many sb.Append(...) with data
  
      sb.Append("&lt;/table&gt;");
      sb.Append("&lt;/x:ExcelWorkSheet&gt;");
      sb.Append("&lt;x:ExcelWorkSheet&gt;");
      sb.Append("&lt;table style='1px solid black; font-size:12px;'&gt;");
  
      //many sb.Append(...) with data
  
      sb.Append("&lt;/table&gt;");
      sb.Append("&lt;/x:ExcelWorkSheet&gt;");
      sb.Append("&lt;/x:ExcelWorkBook&gt;");
  
      HttpContext.Response.AddHeader("content-disposition", "attachment; filename=" + sFileName);
      this.Response.ContentType = "application/vnd.ms-excel";
      this.Response.ContentEncoding = System.Text.Encoding.Default;
  
      System.IO.StringWriter sw = new System.IO.StringWriter();
      System.Web.UI.HtmlTextWriter hw = new HtmlTextWriter(sw);
  
      byte[] buffer = System.Text.Encoding.Default.GetBytes(sb.ToString());
      return File(buffer, "application/vnd.ms-excel");
  </code></pre>
  
  <p>In the code above, I'm creating the workbook with two worksheets, every one with it's own table, but it only creates me one sheet. Can't figure why it don't work.</p>