title: How to set validation for drop down in Excel using c# ClosedXML using method List(String list, Boolean inCellDropdown)
body: <p>Hi All I am trying to create a dropdown list for a column in my excel using ClosedXML library. I am able to create it successfully using the below code.</p>
  
  <pre><code>      using (XLWorkbook wb = new XLWorkbook())
        {
          wb.Worksheets.Add(dt);
          wb.Worksheets.Add(dt2);
          var worksheet2 = wb.Worksheet(2);
          //wb.Worksheet(1).Column(11).SetDataValidation().List("one,two,three", true); This does not work fine
          wb.Worksheet(1).Column(11).SetDataValidation().List(worksheet2.Range("A2:A12"), true);// Works fine
          wb.Worksheet(1).Column(11).SetDataValidation().IgnoreBlanks = true;
          wb.Worksheet(1).Column(11).SetDataValidation().InCellDropdown = true;
          wb.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
          wb.Style.Font.Bold = true;
          wb.SaveAs(targetFile);
        }
  </code></pre>
  
  <p>But I want to do the same thing with another overloaded method of List in SetDataValidation() but that is creating the excel but when I am trying to open it, it says its corrupted. Could you please help me understand why the other overloaded method is not working.</p>
  
  <p>The method in question is <a href="https://github.com/ClosedXML/ClosedXML/blob/develop/ClosedXML/Excel/DataValidation/XLDataValidation.cs#L210" rel="nofollow noreferrer">public void List(String list, Boolean inCellDropdown)</a>. According to the <a href="https://github.com/ClosedXML/ClosedXML/wiki/Data-Validation" rel="nofollow noreferrer">Data Validation wiki page</a> using a string list is possible :</p>
  
  <pre><code>//Pass a string in this format: "Option1,Option2,Option3"
  var options = new List&lt;string&gt;{"Option1","Option2","Option3"};
  var validOptions = $"\"{String.Join(",", options)}\"";
  ws.Cell(1,1).DataValidation.List(validOptions, true);
  </code></pre>