title: Convert Html Table to Excel
body: <p>i want to export an HTML table to excel in MVC.
  I have the following code in my controller:</p>
  
  <pre><code>  public JsonResult ExportToExcel(Control ctl)
          {
  
              Response.Clear();
              Response.ContentType = "application/ms-excel";
              Response.AddHeader("content-disposition", "attachment;filename=ExcelCopy.xls");
              System.IO.StringWriter sw = new System.IO.StringWriter();
              HtmlTextWriter hw = new HtmlTextWriter(sw);
              ctl.RenderControl(hw);
              Response.Write(sw.ToString());
              Response.End();
              return Json(1);
          }
  </code></pre>
  
  <p>and the follwing function in jQuery:</p>
  
  <pre><code> function btnConvertToExcelClick() {
  
          var inputParamtrs={ ????????? }
           $.ajax({
                  type: "POST",
                  url: "/Expenses/ExportToExcel",
                  data: inputParamtrs,
                  success: function (json) {
  
  
                           }
  
  
          });
          return false;
      }
  </code></pre>
  
  <p>I guess what im trying to ask is how to pass the whole HTML table to the JsonResult function <strong>as a Control</strong>. Help!</p>