Exception | Description |
---|---|
System.ArgumentException | Occurs when address is not a valid cell or regions address. |
The is a string containing the list of accepted values or a reference to a cell or region in the same Workbook which contains the accepted values.
If the formula equals a string, it will be a list of accepted value, such as ="A,B,C". If one of the values must contain a double quote ("), the character will be repeated in the list, like so: ="A,""B"",C". This will allow the values A, "B", and C. The separator between values will be a comma (,), unless the decimal separator for the current culture is a comma, in which case the separator will be a semicolon (;).
If the formula equals one or more references, it will be a reference to a single cell or region in the same Workbook. Union, intersection, and range operators are not allowed. An formula might be something like =$A$1 or =Sheet2!$A$1:$A$5. In addition to a single cell or region, a named reference can also be used, but only if it refers to a single cell or region. If a region is specified, or a named reference that refers to a region, the region will consist of a single row or column. A formula that equals an error value can also be returned, but will cause the cell to not accept any values and the drop down to be empty, so it is not very useful.
The address passed in is only needed if relative addresses are used in the the formula. For example, consider the formula applied is =B1, and the data validation rule is applied to the region A1:A5. If you get the formula for A1, the formula =B1 will be returned. If you get the formula for A2, =B2 will be returned. Similarly, for cell A5, =B5 will be returned. However, if the formula contains no references or all absolute references, the address is ignored. So in the previous example, if the original formula was =$B$1, the same formula will be returned regardless of the specified address.
address can be any valid cell or region reference on a worksheet. If a region address is specified, the top-left cell or the region is used. The cell or region specified does not need to have the data validation rule applied to it. Any reference is allowed.
The cell reference mode with which to parse address will be assumed to be A1, unless the data validation rule is applied to a worksheet which is in a workbook, in which case the Workbook.CellReferenceMode will be used.
Target Platforms: Android 4.4+, iOS 8+
Development Environments: Visual Studio 2015+, Visual Studio for Mac Preview, Xamarin for Visual Studio 4.2+
ListDataValidationRule Class
ListDataValidationRule Members
Overload List
TryGetValues Method
GetValuesFormula(String,WorkbookFormat,CellReferenceMode,CultureInfo) Method
SetValuesFormula(String,String) Method
SetValuesFormula(String,String,WorkbookFormat,CellReferenceMode,CultureInfo) Method