title: How can I export an HTML table from a partial view to excel in ASP.NET MVC 5
body: <p>I have spent hours searching all over the internet but it seems no one has a current answer. I have a simple table set up in a PARTIAL view and want to export the data in the html table not from the database. I do not have the option of using any plugins either. I am open to doing it through JavaScript/Jquery but I am fairly new to MVC and I have exhausted other solutions on the internet. </p>
  
  <p><strong>Address Book Summary (Partial View)</strong>:</p>
  
  <pre><code>&lt;table class="table table-bordered table-responsive table-striped" id="tblAddressBook"&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt; @Html.DisplayNameFor(model =&gt; model.Name)&lt;/th&gt;
              &lt;th&gt; @Html.DisplayNameFor(model =&gt; model.Address)&lt;/th&gt;
           &lt;tr&gt;
       &lt;/thead&gt;
       &lt;tbody&gt;
       @foreach (var item in Model)
          {
          &lt;td class="text-right"&gt;@Html.DisplayFor(modelItem =&gt; item.Name)&lt;/td&gt;
          &lt;td class="text-right"&gt;@Html.DisplayFor(modelItem =&gt; item.Address)&lt;/td&gt;
       }
       &lt;/tbody&gt;
       &lt;tfoot&gt;
          &lt;td class="text-right&gt;Model.Sum(model =&gt; model.TotalPeople))&lt;/td&gt;
          &lt;td class="text-right&gt;Model.Sum(model =&gt; model.Addresses))&lt;/td&gt;
       &lt;/tfoot&gt;
  </code></pre>
  
  <p><strong>Address Book</strong></p>
  
  <pre><code>&lt;button type="button" class="btn btn-primary"&gt;
      Export
  &lt;/button&gt;
  &lt;div id="summaryAddressBook"&gt;
              @Html.Partial("AddressBook/_Summary", Model.Peoples)
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>Address Book Controller</strong></p>
  
  <pre><code>public ActionResult Export() {
     Response.ContentType = "application/x-msexcel"; 
     Response.AddHeader("Content-Disposition", "attachment;filename=ExcelFile.xls");
     return View();
  }
  </code></pre>