google-apps-script - 如何比较单元格<->字符串的值
问题描述
我正在寻找将单元格的值与字符串进行比较。(在谷歌脚本中)
function MyMovingTrigger() {
var ss = SpreadsheetApp.openById("MYIDHERE");
var sheet = ss.getSheetByName("SHEETNAMEHERE");
if(sheet.getRange('B2').getValue()=="TRUE") {
//more code here
}
}
//The value in B2 is the following:
//this will either display "TRUE" or "FALSE"
=ISREF(INDIRECT("Copy of Empty"&"!C1"))
我得到的错误如下: ReferenceError: Function function getValue() {/* */} can't be used as the left-hand side of assignment or as an operand of ++ or -- operator. 在 MyMovingTrigger(代码:8)
解决方案
你可以试试这个:
if(sheet.getRange('B2').getValue() == true) {
即去掉 TRUE 周围的引号并放入小写字母。
推荐阅读
- html - 强制 Internet Explorer 在 Edge 中打开网站
- r - 如何将 coord_flip 参数添加到嵌入 ggplot 图的函数中
- ios - 使用 flutter_opencv 插件时运行 pod install 的问题
- java - SSO 使用 SAML 和 Spring Security for REST 服务
- android - Call.Details 类的“DIRECTION_UNKNOWN”到底是什么?
- python - Python asyncio:Queue.join() 仅在未引发异常时完成,为什么?(上下文:编写异步映射函数)
- javascript - 使用 v-if 时什么都不显示
- android - 如何在 ViewPager2 中水平滚动 WebView
- python - Python MySQL.connector - MySQL 连接不可用
- python-3.x - 对用于处理 Python 生成器中的参数的语法感到困惑