[英]Apps script conditional formatting for value not in array
I have a column containing US state abbreviations.我有一列包含美国各州的缩写。 I'd like to have an array of all 50 states:
我想要一个包含所有 50 个状态的数组:
const states = ['DE','AK','TX','CA' .........]
that the value of each cell in the column is compared against.与列中每个单元格的值进行比较。 If its not one of the states I'd like to format it red.
如果它不是我想将其格式化为红色的状态之一。
I've looked at conditional formatting ( https://developers.google.com/apps-script/reference/spreadsheet/conditional-format-rule-builder#whenTextDoesNotContain(String) ) where they have sample code like:我查看了条件格式( https://developers.google.com/apps-script/reference/spreadsheet/conditional-format-rule-builder#whenTextDoesNotContain(String) ),其中有示例代码,例如:
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
.whenTextDoesNotContain("hello")
.setBackground("#FF0000")
.setRanges([range])
.build();
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);
Is there a conditional rule that would allow (in pseudocode):是否有条件规则允许(在伪代码中):
.whenTextDoesNotContain(states)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.