Google电子表格中带有条件格式的色标

Und*_*nes 15 google-docs google-sheets google-apps-script gs-conditional-formatting

我需要在Google电子表格中的行或列上使用色标,就像Microsoft Office Excel条件格式提供的色标一样:

Microsoft Excel中的条件格式内的色标

我找不到可以完成这项工作的Google Script Gallery脚本.手动为所有可能的值设置条件格式不是解决方案.

我的能力仅限于写一个合适的剧本.因此我想出了这个伪代码:

colorRangeFormatting(cellRange, minColorHex, maxColorHex)
{
  float cellValueMax = getHighestValue(cellRange);
  float cellValueMin = getLowestValue(cellRange);
  int cellCount = range.length;
  int colorValueMax = maxColorHex.toInt();
  int colorValueMin = minColorHex.toInt();

  int colorSize = colorValueMax - colorValueMin;
  cellValueSize = cellValueMax - celLValueMin;



  int colorIncrement = (colorSize/cellValueSize).Round();
  int[] colorGradients = colorGradients[colorSize];

  foreach(int color in colorGradients)
  {
    color = colorValueMin + colorIncrement;
    colorIncrement = colorIncrement + colorIncrement;
  }

  int i = 0;
  foreach(Cell c in cellRange)
  {
    c.setBackgroundColor(colorGradients[i].ToHex());
    i++;
  }
}
Run Code Online (Sandbox Code Playgroud)
  • 有没有办法本地做?
  • 或者是否有任何google应用程序脚本执行此操作(我忽略了)?
  • 还是有人愿意帮我把我的伪代码带到适当的电子表格谷歌应用程序脚本?

谢谢

Und*_*nes 17

Google表格现在支持菜单"格式>条件格式..."下的条件色阶,然后选择"色阶"选项卡.

Google表格色标