title: Asp.net mvc 5 with closedxml. not able to export to excel. getting virus detection message
body: <p>I am trying to export data to excel using closedxml api but getting virus detected error on export</p>
  
  <p>My code is below</p>
  
  <pre><code>[HttpGet]
          public ActionResult ExportToExcelNew()
          {
              string sheetName = "Report";
              var userClaims = DbAccessWebApiHandler.GetUserClaimAccesshistory(new DateSelection
              {
                  StartDate = DateTime.Now.AddDays(-60),
                  EndDate = DateTime.Now
              });
  
              if (userClaims != null)
              {
                  DataTable dt = new DataTable();
                  dt.Columns.Add("UserName");
                  dt.Columns.Add("Email");
                  dt.Columns.Add("Claim");
                  dt.Columns.Add("AccessedOn");
  
  
                 foreach (var item in userClaims)
                 {
                      dt.Rows.Add(item.UserName, item.Email, item.Claim, item.AccessedOn);
                  }
                  XLWorkbook wb = new XLWorkbook(XLEventTracking.Disabled);
                  var ws = wb.Worksheets.Add(sheetName);
                  ws.Cell(2, 1).InsertTable(dt);
                  using (var stream = new MemoryStream())
                  {
                      wb.SaveAs(stream);
                      stream.Flush();
                     return new FileContentResult(stream.ToArray(),"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
                      {
                          FileDownloadName = "Report.xlsx"
                      };
                  }
              }
  
              return View("Index");
          }
  </code></pre>
  
  <p>While other simple sort of export works which code looks like</p>
  
  <pre><code>[HttpGet]
          public ActionResult ExportToExcel(DateTime? fromDate, DateTime? toDate)
          {
              if (!fromDate.HasValue) fromDate = DateTime.Now.Date;
              if (!toDate.HasValue) toDate = fromDate.GetValueOrDefault(DateTime.Now.Date).Date.AddDays(1);
              if (toDate &lt; fromDate) toDate = fromDate.GetValueOrDefault(DateTime.Now.Date).Date.AddDays(1);
              ViewBag.fromDate = fromDate;
              ViewBag.toDate = toDate;
  
              var userClaims = DbAccessWebApiHandler.GetUserClaimAccesshistory(new DateSelection
              {
                  StartDate = fromDate.Value,
                  EndDate = toDate.Value
              });
  
  
              if (userClaims != null)
              {
                  var gv = new GridView();
  
                  gv.AutoGenerateColumns = false;
                  gv.Columns.Add(new BoundField { HeaderText = "UserName", DataField = "UserName" });
                  gv.Columns.Add(new BoundField { HeaderText = "Email", DataField = "Email" });
                  gv.Columns.Add(new BoundField { HeaderText = "Accessed", DataField = "Claim" });
                  gv.Columns.Add(new BoundField { HeaderText = "Date", DataField = "AccessedOn" });
  
                  var dt = new DataTable();
                  dt.Columns.Add("UserName");
                  dt.Columns.Add("Email");
                  dt.Columns.Add("Claim");
                  dt.Columns.Add("AccessedOn");
  
  
                  foreach (var item in userClaims)
                  {
                      dt.Rows.Add(item.UserName, item.Email, item.Claim, item.AccessedOn);
                  }
  
                  gv.DataSource = dt;
                  gv.DataBind();
  
                  for (var i = 0; i &lt; userClaims.Count; i++)
                  {
                      gv.Rows[i].Height = 40;
                  }
  
                  Response.ClearContent();
                  Response.Buffer = true;
                  Response.AddHeader("content-disposition", "attachment; filename=Reports.xls");
                  Response.ContentType = "application/ms-excel";
                  Response.Charset = "";
                  var sw = new StringWriter();
                  var htw = new HtmlTextWriter(sw);
                  gv.RenderControl(htw);
                  Response.Output.Write(sw.ToString());
                  Response.Flush();
                  Response.End();
              }
  
  
              return View("Index");
          }
  </code></pre>
  
  <p>I have Windows 8.1 OS</p>