title: How to assign a list to a Cell(Dropdown format) in closedXML while Exporting to Excel
body: <p>I am just trying to Export a <code>Datatable</code> (<code>Datatable</code> doesn't have any data - having only header). In addition, i have a <code>List&lt;String&gt;</code> which i want to append to the column, such that, after export to excel that column (all cells except header) should contain list data as <code>Dropdown</code> format.</p>
  
  <p>I have googled a lot and couldn't able to find any solutions.
  Below are the links which i have visited but no luck.</p>
  
  <p><a href="https://stackoverflow.com/questions/32708824/create-dropdown-list-using-closedxml">StackOverflow</a></p>
  
  <p><a href="https://closedxml.codeplex.com/documentation" rel="nofollow noreferrer">Codeplex - ClosedXML</a></p>
  
  <p>And below are the one what i have tried so far.</p>
  
  <pre><code>    private void ExcelExport(DataTable dt, GridView Template)
      {
          bool isListRequired = false;
          List&lt;string&gt; groupCodeList = new List&lt;string&gt;(); ;
          Template.DataBind();
          if (Template.HeaderRow != null)
          {
              foreach (TableCell cell in Template.HeaderRow.Cells)
              {
                  if (cell.Text == "ActivityGroup_Code")
                  {
                      isListRequired = true;
                      groupCodeList = db.PMS_M_ActivityGroup.Select(a =&gt; a.ActivityGroup_Code).ToList();
                  }
                      dt.Columns.Add(cell.Text);
              }
  
              var workbook = new XLWorkbook();
              var returnValue = workbook.AddWorksheet(dt);
              var worksheet = workbook.Worksheet(1);
              if (isListRequired)
              {
                  //worksheet.Cell("E2").DataValidation.List(string.Join("",groupCodeList.ToArray()));
                  //worksheet.Cell(2,5).InsertData(groupCodeList);
  
                  // Trying to add a list to the Cell (E2) - and applying datavalidation to the Column (5th column - E Range)
                  // Dropdown is created in excel(with blank) but data is not population to that dropdown
                  worksheet.Cell(2, 5).InsertData(groupCodeList);
                  worksheet.Column(5).SetDataValidation().List(string.Join("", groupCodeList.ToArray()));
              }
  
              Response.ClearContent();
              Response.Buffer = true;
              Response.AddHeader("content-disposition", "attachment; filename=ExcelFormat.xlsx");
              Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
              Response.Charset = "";
              using (MemoryStream MyMemoryStream = new MemoryStream())
              {
                  workbook.SaveAs(MyMemoryStream);
                  MyMemoryStream.WriteTo(Response.OutputStream);
                  Response.Flush();
                  Response.End();
              }
          }
      }
  </code></pre>
  
  <p>And the code where i am calling this method is </p>
  
  <pre><code> List&lt;PMS_M_ActivityGroup&gt; activitygroup = new List&lt;PMS_M_ActivityGroup&gt;();
   activitygroup = db.PMS_M_ActivityGroup.Select(a =&gt; a).ToList();
   DataTable dt2 = new DataTable("Excel Template");
   GridView Template2 = new GridView();
   Template2.DataSource = activitygroup;
   ExcelExport(dt2, Template2);
  </code></pre>
  
  <p>Request you to provide me the solution how to achieve the required functionality.</p>
  
  <p>Thank you</p>