title: OpenXml DataValidation set predefined List for columns
body: <p>I am using OpenXml to create Excel file and export table data. One of the scenario is I want a column to have dropdown of predefined values, say like true and false. I followed <a href="https://stackoverflow.com/questions/22808284/how-to-set-a-list-for-data-validations-in-column-columns-of-excel-file-using-ope">this</a> question and wrote code as below</p>
  
  <pre><code>DataValidation dataValidation = new DataValidation
  {
      Type = DataValidationValues.List,
      AllowBlank = true,
      SequenceOfReferences = new ListValue&lt;StringValue&gt;() { InnerText = "B1" },
      //Formula1 = new Formula1("'SheetName'!$A$1:$A$3") // this was used in mentioned question
      Formula1 = new Formula1("True,False") // I need predefined values.
  };
  
  DataValidations dvs = worksheet.GetFirstChild&lt;DataValidations&gt;(); //worksheet type =&gt; Worksheet
  if (dvs != null)
  {
      dvs.Count = dvs.Count + 1;
      dvs.Append(dataValidation);
  }
  else
  {
      DataValidations newDVs = new DataValidations();
      newDVs.Append(dataValidation);
      newDVs.Count = 1;
      worksheet.Append(newDVs);
  }
  </code></pre>
  
  <p>If I use it with SheetName with cell values range, it works fine, but if I add string, it throws me error "Unreadable content found" and removes datavalidation node. </p>
  
  <p>How to add values for list dropdown validation in formula itself. XML it creates for manually added(by editing in excel application) list values is <code>&lt;formula1&gt;"One,Two"&lt;/formula1&gt;</code> (observed xml for excel file)</p>