如何判断单元格值是否已通过验证 [英] How to tell if a cell value has passed validation
问题描述
我熟悉Google Apps脚本 DataValidation 目的.获取并设置验证标准.但是如何以编程方式判断单元格值是否实际有效.因此,我可以在电子表格中看到红色验证失败的小消息,但是可以通过代码来获取当前未通过验证的单元格的事实吗?
I am familiar with the Google Apps script DataValidation object. To get and set validation criteria. But how to tell programatically if a cell value is actually valid. So I can see the little red validation fail message in the spreadsheet but can the fact the cell is currently failing validation be picked up thru code?
我试图查看是否有一个单元格属性可以告诉您这一点,但是没有.另外,我也在寻找某种DataValidation验证"方法-即根据验证规则测试值,但那里也没有
I have tried to see if there is a cell property that tells you this but there is not. Also I looked for some sort of DataValidation "validate" method - i.e. test a value against validation rules, but nothing there either
有什么想法吗?这可能吗?
Any ideas? Is this possible??
推荐答案
针对您问题的具体答案,Google Apps脚本中没有方法可以返回Range
的有效性,例如.isValid().如您陈述的那样,您可以使用Range.getDataValidations()
反向编程一个程序化程序,然后解析其结果,以再次验证Range.getValues()
调用的值.
Specific answer to your question, there is no method within Google Apps Script that will return the validity of a Range
such as .isValid(). As you state, you could reverse engineer a programatic one using Range.getDataValidations()
and then parsing the results of that in order to validate again the values of a Range.getValues()
call.
It's a good suggestion. I've added a feature request to the issue tracker -> Add a Star to vote it up.
这篇关于如何判断单元格值是否已通过验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!