title: Export To excel with formatting
body: <p>I was trying to export a table from database to Excel using Gridview in MVC 4. Can anybody tell me how to give colors to the exported rows in excel sheet?</p>
  
  <pre><code>public ActionResult ExportToExcel()
  {
          GridView gv = new GridView();
          gv.DataSource = db.StudentRecords.ToList();
          gv.DataBind();
          Response.ClearContent();
          Response.Buffer = true;
          Response.AddHeader("content-disposition", "attachment; filename=Marklist.xls");
          Response.ContentType = "application/ms-excel";
          Response.Charset = "";
          StringWriter sw = new StringWriter();
          HtmlTextWriter htw = new HtmlTextWriter(sw);
          gv.RenderControl(htw);
          Response.Output.Write(sw.ToString());
          Response.Flush();
          Response.End();
          return RedirectToAction("index");
  }
  </code></pre>