Я нашел решение.Это прямо вперед.Мне пришлось использовать XlFormatConditionType.xlCellValue
вместо TextString:
//Drop-down List
var list = new System.Collections.Generic.List<string>();
list.Add("okay");
list.Add("delete");
list.Add("else (Comment)");
var flatList = string.Join(",", list.ToArray());
var celldd = (Excel.Range)mysheet.Cells[row_counter, 10];
celldd.Validation.Delete();
try
{
int type = celldd.Validation.Type;
Console.WriteLine("The validation have already been added");
}
catch (System.Runtime.InteropServices.COMException)
{
celldd.Validation.Add(
Excel.XlDVType.xlValidateList,
Excel.XlDVAlertStyle.xlValidAlertInformation,
Excel.XlFormatConditionOperator.xlBetween,
flatList, misValue);
}
celldd.Validation.InCellDropdown = true;
celldd.Validation.IgnoreBlank = true;
celldd.Locked = false;
celldd.Value2 = "Choose";
celldd.Interior.Color = ColorTranslator.ToOle(Color.Plum);
//Conditional Formatting
Excel.FormatCondition condition1 = mysheet.get_Range("J2:J10",
Type.Missing).FormatConditions.Add(Excel.XlFormatConditionType.xlCellValue, Excel.XlFormatConditionOperator.xlEqual, "=\"delete\"", misValue, misValue, misValue, misValue, misValue);
condition1.Interior.ColorIndex = 3; //red
Excel.FormatCondition condition2 = mysheet.get_Range("J2:J10",
Type.Missing).FormatConditions.Add(Excel.XlFormatConditionType.xlCellValue, Excel.XlFormatConditionOperator.xlEqual, "=\"okay\"", misValue, misValue, misValue, misValue, misValue);
condition2.Interior.ColorIndex = 43; //green
Excel.FormatCondition condition3 = mysheet.get_Range("J2:J10",
Type.Missing).FormatConditions.Add(Excel.XlFormatConditionType.xlCellValue, Excel.XlFormatConditionOperator.xlEqual, "=\"else (Comment)\"", misValue, misValue, misValue, misValue, misValue);
condition3.Interior.ColorIndex = 44; //yellow