Adds a list data-validation rule to the specified classic XLS worksheet range.
Syntax
function AddListValidation(ARange, AItems: WideString): Integer;
| ARange |
WideString. A cell or A1-style range that receives the validation rule. |
| AItems |
WideString. A comma-separated inline list, a quoted list formula, or a worksheet range reference formula. |
Remarks
The method writes BIFF8 DVAL and DV records for Excel 97-2003 workbooks. Inline lists such as Yes,No,Maybe are wrapped as an Excel list formula automatically. Pass a quoted formula or a formula containing a sheet reference when you need to control the source expression directly.
Example
This example adds a dropdown list to cells A1 through A10.
Workbook := TXLSWorkbook.Create;
try
Sheet := Workbook.Sheets[1];
Sheet.AddListValidation('A1:A10', 'Yes,No,Maybe');
Workbook.SaveAs('validated.xls', xlExcel97);
finally
Workbook.Free;
end;
See Also