我正在使用Google脚本来更改Google工作表中某些行单元格的背景色。由于某种原因,当我将它们作为一系列单元格的函数运行时(不是我尝试过的那样),setBackgroundColor('white')可以工作,而setBackgroundColorTransparent()则调用"TypeError:不是函数“消息。我是否遗漏了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)发布于 2020-06-09 01:16:47
我相信你的目标如下。
setBackgroundColorTransparent()。为了这个,这个答案怎么样?
修改要点:
setBackgroundColorTransparent()方法。我认为你的问题是这个原因。我认为在您的情况下,可以使用幻灯片服务中类setBackgroundColorTransparent()的TextStyle方法。参考setBackgroundColor方法。在这种情况下,请使用setBackground。因此,当您想将背景色设置为默认颜色时,下面的修改如何?
发自:
currentRow.setBackgroundColor('#F87CF8');至:
currentRow.setBackground('#F87CF8');和
发自:
currentRow.setBackgroundColorTransparent();至:
currentRow.setBackground(null);注意:
setBackgroundColor方法。但从OP的答复中可以看出,该方法是可行的。参考资料:
https://stackoverflow.com/questions/62273159
复制相似问题