C # Interop Checklist

I have implemented code that adds data validation to cells from a specified range, but values ​​containing, are broken into pieces ...

This is my code.

 var listFormats = new List<string>(); listFormats.Add("US punctuation + alphanumeric lowercase:[a-z0-9,.?;:!&()_'" + '"' + "]+"); listFormats.Add("US punctuation + alphanumeric uppercase:[A-Z0-9,.?;:!&()_'" + '"' + "]+"); listFormats.Add("US punctuation + alphanumeric mixedcase:[A-Za-z0-9,.?;:!&()_'" + '"' + "]+"); var flatListFormats = string.Join(",", listFormats.ToArray()); rng.Validation.Add(XlDVType.xlValidateList, XlDVAlertStyle.xlValidAlertInformation, XlFormatConditionOperator.xlBetween, flatListDelimiters, Type.Missing); 

And here is what I get in the validation list:
enter image description here

Instead

 US punctuation + alphanumeric lowercase:[a-z0-9,.?;:!&()_'"]+ US punctuation + alphanumeric uppercase:[A-Z0-9,.?;:!&()_'" US punctuation + alphanumeric mixedcase:[A-Za-z0-9,.?;:!&()_'" 
+1
source share
1 answer

Get a list in a range and specify a range for checking data. Here are a few pseudo codes to get you started:

 // Get the list you want into a cell range worksheet.Range("A1:A3").Value = listFormats; // Reference the range when applying the validation rng.Validation.Delete(); rng.Validation.Add(... xlBetween, "='" + worksheet.Name + "'!" + worksheet.Range("A1:A3").Address); 
+1
source

Source: https://habr.com/ru/post/1244050/


All Articles