spreadsheetAddDataValidation

Adds a data validation rule to the active sheet of a spreadsheet workbook. Pass a struct with range (A1 cell range), type (list, whole, decimal, textLength, date or custom, default list), operator (between, notBetween, greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual, equal or notEqual) and the bound expressions formula1 and formula2. For a list type, formula1 is a quoted, comma-separated list such as "Red,Green,Blue" or a range reference. Blank cells are allowed. The fluent member form is addDataValidation({...}).

spreadsheetAddDataValidation(spreadsheetObj, validationStruct) → returns any

This function requires RustCFML.  Not supported on Lucee, Adobe ColdFusion, etc.

Argument Reference

spreadsheetObj any
Required

The spreadsheet workbook object to add the validation to.

validation struct
Required

Struct describing the rule: range (A1 cell range), type (list|whole|decimal|textLength|date|custom), operator, formula1, formula2.

Compatibility

RustCFML:

Not supported on wasm32.

Examples
Sample code invoking the spreadsheetAddDataValidation function

A dropdown of Red/Green/Blue on A2:A10.

wb = Spreadsheet("xlsx");
spreadsheetAddDataValidation(wb, {
	range: "A2:A10",
	type: "list",
	formula1: "\"Red,Green,Blue\""
});

A numeric between rule on B2:B20.

wb = Spreadsheet("xlsx");
spreadsheetAddDataValidation(wb, {
	range: "B2:B20",
	type: "whole",
	operator: "between",
	formula1: "1",
	formula2: "10"
});

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub