Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google sheets 基于值和其他单元格的NewConditionalFormature_Google Sheets_Google Sheets Api_Spreadsheet - Fatal编程技术网

Google sheets 基于值和其他单元格的NewConditionalFormature

Google sheets 基于值和其他单元格的NewConditionalFormature,google-sheets,google-sheets-api,spreadsheet,Google Sheets,Google Sheets Api,Spreadsheet,我正在尝试使用应用程序脚本newConditionalFormatRule根据其他单元格设置单元格的颜色 假设我有: A1 = 40 B1 = 90 然后我想A1得到绿色,因为它比B1低。 我想B1变成红色,因为它比A1高 有没有办法让我在rulset中创建这种行为 比如: 此示例创建一个条件格式规则,该规则为范围内的值设置从绿色到红色的颜色渐变。最低值为绿色,最高值为红色 function CFtest2() { var theSheet = SpreadsheetApp.getActi

我正在尝试使用应用程序脚本
newConditionalFormatRule
根据其他单元格设置单元格的颜色

假设我有:

A1 = 40
B1 = 90
然后我想A1得到绿色,因为它比B1低。 我想B1变成红色,因为它比A1高

有没有办法让我在rulset中创建这种行为

比如:


此示例创建一个条件格式规则,该规则为范围内的值设置从绿色到红色的颜色渐变。最低值为绿色,最高值为红色

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]);
};

此示例创建一个条件格式规则,该规则为范围内的值设置从绿色到红色的颜色渐变。最低值为绿色,最高值为红色

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]);
};