WPS 基础接口 > 表格 API 参考 > Validation > Validation 对象

代表工作表区域的数据有效性规则。

示例

使用 Validation 属性可返回 Validation 对象。下例更改单元格 E5 的数据有效性规则。

示例代码
Range("e5").Validation.Modify(xlValidateList, xlValidAlertStop, "=$A$1:$A$10")

使用 Add 方法可将数据有效性添加到某个区域并创建一个新的 Validation 对象。此示例向单元格 E5 添加数据有效性检验。

示例代码
let rng = Range("e5").Validation
rng.Add(xlValidateWholeNumber, xlValidAlertInformation, "5", "10")
rng.InputTitle = "Integers"
rng.ErrorTitle = "Integers"
rng.InputMessage = "Enter an integer from five to ten"
rng.ErrorMessage = "You must enter a number from five to ten"


请参阅