错误:setBackgroundColorTransparent()不是Google Apps脚本中的函数

疯狂心理学家

我正在使用Google Apps脚本更改Google表格中某些单元格行的背景颜色。由于某些原因,当我将它们作为一系列单元格的函数运行时(不是我尝试过的其他方法),setBackgroundColor('white')可以工作,而setBackgroundColorTransparent()会调用“ TypeError:not a function”消息。我是否缺少setBackgroundColorTransparent()的用法或语法?

我的代码:

function colorSundays() {
  var maxColumns = sheet.getMaxColumns();
  for (i = 1; i <= 31; i++) {
    var currentCell = sheet.getRange(i, 1);
    var value = currentCell.getValues();
    if (value == 'Sunday') {
      var currentRow = sheet.getRange(i, 1, 1, maxColumns);
      currentRow.setBackgroundColor('#F87CF8');
    } else {
      var currentRow = sheet.getRange(i, 1, 1, maxColumns);
//      currentRow.setBackgroundColor('white');
      currentRow.setBackgroundColorTransparent(); // Preferred, but now working right now.
    }
  }
}

错误信息:

[20-06-08 19:09:04:246 CDT] TypeError: currentRow.setBackgroundColorTransparent is not a function
    at colorSundays(Code:52:18)
    at setThisMonth(Code:61:3)
Tanaike

我相信您的目标如下。

  • 为了将背景色设置为默认颜色,您尝试使用setBackgroundColorTransparent()
  • 您要设置单元格的背景色。

为此,这个答案如何?

修改要点:

  • 不幸的是,setBackgroundColorTransparent()电子表格服务中未包含的方法我认为您的问题的原因是这样的。我认为在您的情况下,setBackgroundColorTransparent()可以使用Slides Service中的TextStyle类的方法参考
  • 的方法setBackgroundColor未包含在“类别范围”中。在这种情况下,请使用setBackground

因此,当您要将背景色设置为默认值时,如何进行以下修改?

从:

currentRow.setBackgroundColor('#F87CF8');

至:

currentRow.setBackground('#F87CF8');

从:

currentRow.setBackgroundColorTransparent();

至:

currentRow.setBackground(null);

注意:

  • 的方法setBackgroundColor未包含在“类别范围”中。但是从OP的答复中,发现可以使用此方法。

参考:

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

doGet函数中的Google Apps脚本返回图像

来自分类Dev

函数将未定义的函数传递给Google Apps脚本中的被调用函数

来自分类Dev

Google Apps 脚本:“找不到脚本函数”错误

来自分类Dev

避免Google Apps脚本中的formatDate错误

来自分类Dev

indexOf依赖于父函数的变量(数组)在Map函数中运行(Google Apps脚本)

来自分类Dev

Google Apps脚本函数的返回值未显示在电子表格中

来自分类Dev

Google Apps脚本中的成功处理程序从服务器函数接收到空值

来自分类Dev

在Google Apps脚本中通过引用在函数之间传递变量

来自分类Dev

Google Apps脚本:如何从复选框列表中的提交函数访问数组值?

来自分类Dev

在简单的 Google Apps 脚本中显示错误,如何隐藏

来自分类Dev

Google Apps 脚本中的 Google Drive 通知

来自分类Dev

Google App Engine与 Google Apps脚本(在Business Apps中)

来自分类Dev

遍历Google Apps脚本中的对象

来自分类Dev

在Google Apps脚本中设置超时

来自分类Dev

在Google Apps脚本中循环数组

来自分类Dev

在Google Apps脚本中创建枚举ButtonSet

来自分类Dev

容器绑定Google Apps脚本中的jQuery?

来自分类Dev

侧边栏中的Google Apps脚本授权

来自分类Dev

Google Apps脚本中的Angular JS

来自分类Dev

Google Apps脚本中PropertiesServices的异常行为

来自分类Dev

在Google Apps脚本中记录范围

来自分类Dev

如何限制Google Apps脚本中的行数?

来自分类Dev

在Google Apps脚本中创建条纹令牌

来自分类Dev

在Google Apps脚本中返回数组

来自分类Dev

Apps脚本中的Google Docs API

来自分类Dev

Google Apps脚本中的附件问题

来自分类Dev

Chrome扩展程序中的Google Apps脚本?

来自分类Dev

容器绑定Google Apps脚本中的jQuery?

来自分类Dev

在Google Apps脚本中删除命名范围

Related 相关文章

  1. 1

    doGet函数中的Google Apps脚本返回图像

  2. 2

    函数将未定义的函数传递给Google Apps脚本中的被调用函数

  3. 3

    Google Apps 脚本:“找不到脚本函数”错误

  4. 4

    避免Google Apps脚本中的formatDate错误

  5. 5

    indexOf依赖于父函数的变量(数组)在Map函数中运行(Google Apps脚本)

  6. 6

    Google Apps脚本函数的返回值未显示在电子表格中

  7. 7

    Google Apps脚本中的成功处理程序从服务器函数接收到空值

  8. 8

    在Google Apps脚本中通过引用在函数之间传递变量

  9. 9

    Google Apps脚本:如何从复选框列表中的提交函数访问数组值?

  10. 10

    在简单的 Google Apps 脚本中显示错误,如何隐藏

  11. 11

    Google Apps 脚本中的 Google Drive 通知

  12. 12

    Google App Engine与 Google Apps脚本(在Business Apps中)

  13. 13

    遍历Google Apps脚本中的对象

  14. 14

    在Google Apps脚本中设置超时

  15. 15

    在Google Apps脚本中循环数组

  16. 16

    在Google Apps脚本中创建枚举ButtonSet

  17. 17

    容器绑定Google Apps脚本中的jQuery?

  18. 18

    侧边栏中的Google Apps脚本授权

  19. 19

    Google Apps脚本中的Angular JS

  20. 20

    Google Apps脚本中PropertiesServices的异常行为

  21. 21

    在Google Apps脚本中记录范围

  22. 22

    如何限制Google Apps脚本中的行数?

  23. 23

    在Google Apps脚本中创建条纹令牌

  24. 24

    在Google Apps脚本中返回数组

  25. 25

    Apps脚本中的Google Docs API

  26. 26

    Google Apps脚本中的附件问题

  27. 27

    Chrome扩展程序中的Google Apps脚本?

  28. 28

    容器绑定Google Apps脚本中的jQuery?

  29. 29

    在Google Apps脚本中删除命名范围

热门标签

归档