如何在Google脚本中更改整个行的颜色? [英] How to change whole row color in google script?

查看:128
本文介绍了如何在Google脚本中更改整个行的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改Google脚本中活动单元格的整行背景颜色?

How can I change whole rows background color of active cell in google script?

SpreadsheetApp.getActiveRange().setBackgroundRGB(224, 102, 102)

上面的代码仅更改活动单元格的背景颜色. 但是我需要更改活动单元格背景的行.

The code above only changes active cells background color. But I need to change row of active cells background.

推荐答案

类范围类表中,您可以使用一些方法来选择单元格所在的行.这类似于

Class Range and Class Sheet have methods you can use to pick the row that the cell is in. This is similar to the technique used in this answer.

SpreadsheetApp.getActiveSheet().getRange(SpreadsheetApp.getActiveRange().getRow(),1,1,SpreadsheetApp.getActiveSheet().getLastColumn()).setBackgroundRGB(224, 102, 102);

这做同样的事情,分解为易于阅读的行:

This does the same thing, broken down into easier-to-read lines:

var sheet = SpreadsheetApp.getActiveSheet();
var activeRange = SpreadsheetApp.getActiveRange();
var changeRange = sheet.getRange(activeRange.getRow(),1,1,sheet.getLastColumn());
changeRange.setBackgroundRGB(224, 102, 102);

这篇关于如何在Google脚本中更改整个行的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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