基于值和其他单元格的 newConditionalFormatRule
newConditionalFormatRule based on value and other cell
我正在尝试使用应用程序脚本 newConditionalFormatRule
根据其他单元格设置单元格的颜色。
假设我有这个:
A1 = 40
B1 = 90
那我想让A1变成绿色,因为它比B1低。
我希望 B1 变红,因为它比 A1 高。
有没有办法让我在规则集中创建这种行为?
喜欢:
var rule3 = SpreadsheetApp.newConditionalFormatRule()
.//check other cell if greater thing.
.setBackground("#EEED09")
.setRanges([range])
.build();
此示例创建条件格式设置规则,为范围内的值设置从绿色到红色的颜色渐变。最低值为绿色,最高值为红色。
function CFtest2() {
var theSheet = SpreadsheetApp.getActive();
var area = theSheet.getRange('A1:B1');
var newRule = SpreadsheetApp.newConditionalFormatRule();
newRule
.setRanges([area])
.setGradientMinpoint('#00FF00')
.setGradientMidpointWithValue('#FFFFFF', SpreadsheetApp.InterpolationType.PERCENTILE, '50')
.setGradientMaxpoint('#FF0000')
.build();
theSheet.getActiveSheet().setConditionalFormatRules([newRule]);
};
我正在尝试使用应用程序脚本 newConditionalFormatRule
根据其他单元格设置单元格的颜色。
假设我有这个:
A1 = 40
B1 = 90
那我想让A1变成绿色,因为它比B1低。 我希望 B1 变红,因为它比 A1 高。
有没有办法让我在规则集中创建这种行为?
喜欢:
var rule3 = SpreadsheetApp.newConditionalFormatRule()
.//check other cell if greater thing.
.setBackground("#EEED09")
.setRanges([range])
.build();
此示例创建条件格式设置规则,为范围内的值设置从绿色到红色的颜色渐变。最低值为绿色,最高值为红色。
function CFtest2() {
var theSheet = SpreadsheetApp.getActive();
var area = theSheet.getRange('A1:B1');
var newRule = SpreadsheetApp.newConditionalFormatRule();
newRule
.setRanges([area])
.setGradientMinpoint('#00FF00')
.setGradientMidpointWithValue('#FFFFFF', SpreadsheetApp.InterpolationType.PERCENTILE, '50')
.setGradientMaxpoint('#FF0000')
.build();
theSheet.getActiveSheet().setConditionalFormatRules([newRule]);
};