title: Color scale with conditional formatting in Google Spreadsheet
body: <p>I need a color scale on a row or column in Google Spreadsheet, like the one provided by Microsoft Office <a href="http://office.microsoft.com/en-001/excel-help/quick-start-apply-conditional-formatting-HA010370614.aspx" rel="noreferrer">Excel conditional formatting with color scale</a>:</p>
  
  <p><img src="https://i.stack.imgur.com/qQ3oD.jpg" alt="Color scale within Conditional Formatting in Microsoft Excel"></p>
  
  <p>I couldn't find a Google Script Gallery Script that can do exactly this job. Setting conditional formatting manually for all possible values is not a solution.</p>
  
  <p>My abilities are limited to write a proper script. Therefore I came up with this pseudo code:</p>
  
  <pre><code>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++;
    }
  }
  </code></pre>
  
  <ul>
  <li>Is there any way to do it natively?</li>
  <li>or are there any google app scripts that do this (which I overlooked)?</li>
  <li>or is someone willing to help me bring my pseudo-code to a proper
  google app script for spreadsheet?</li>
  </ul>
  
  <p>Thanks</p>