Sheet.get_Range( "D2", string.Format("D{0}", MAX_ROWS)).Validation .Add(E.XlDVType.xlValidateList, Type.Missing, E.XlFormatConditionOperator.xlBetween, string.Join(",", CountryCollection.Select(x=>x.CountryName.Replace(",",")).ToArray()));
The above code will help generate a drop-down list in a newly opened excel file, but as soon as the user saves the sheet, the drop-down list will disappear. The changes made by the user will remain there, but the drop-down list will disappear. Any idea?
UPDATE:
Currently suspecting the reason the dropdown is gone is explained by the following code
void WB_BeforeSave(bool SaveAsUI, ref bool Cancel) { workSheet.get_Range(START_CELL, string.Format(END_CELL, MAX_ROWS)).Validation.Delete(); }
I tried to comment on the above code so that the validation is not deleted, however, when I try to open the excel sheet manually, Microsoft Excel detects that it is checking for unreadable content and automatically deletes it.
source share