Google应用程序脚本 - 如何判断单元格值是否已通过验证 [英] Google apps script - how to tell if a cell value has passed validation

查看:79
本文介绍了Google应用程序脚本 - 如何判断单元格值是否已通过验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我熟悉Google Apps脚本 DataValidation 对象。获取和设置验证标准。但是如何以编程方式告诉单元格值是否真的有效。所以我可以在电子表格中看到小小的红色验证失败消息,但是单元格目前是否通过代码验证失败?



我试图查看是否有一个单元属性告诉你这个,但没有。此外,我寻找某种DataValidationvalidate方法 - 即根据验证规则测试一个值,但没有任何内容



任何想法?这是可能的吗?



非常感谢

Chris

解决方案

针对您的问题的具体答案是,Google Apps脚本中没有方法可以返回范围的有效性,例如。已验证()。正如您所说的,您可以使用 Range.getDataValidations()反向设计一个程序化程序,然后解析结果以再次验证 Range.getValues()调用。



这是一个很好的建议。我向问题跟踪器添加了功能请求 - > 添加明星将其投票


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?

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??

Many thanks

Chris

解决方案

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.

这篇关于Google应用程序脚本 - 如何判断单元格值是否已通过验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆