title: How to export data to excel using mvc without using third party control
body: <p>I want to export data to excel both in .xls and .xlsx format in asp.net
  MVC without using any third party control. </p>
  
  <p>I tried using following code but it doesn't support .xlsx format.</p>
  
  <pre><code>Response.AddHeader("Content-Disposition", "attachment; 
  filename=test.xlsx");
  Response.ContentType = "application/ms-excel";
  Response.Write(sw.ToString());
  Response.End();
  </code></pre>
  
  <p>Pls give me solution.</p>