title: Google Apps Script getRanges returns a list with a single Range
body: <p>I am trying to get the range of selected cells in Google Apps Scripts and chain them into an <code>HtmlOutput</code>.</p>
  
  <p>One of the columns in my spreadsheet has HTML input. For example: <code>&lt;p&gt;Hello &lt;em&gt;World&lt;/em&gt;&lt;/p&gt;</code>. The idea is to simply give a nice preview of the HTML.</p>
  
  <p>My use case is that the user selects a range of cells (multiple rows, same column) by dragging their cursor across, and then previews content for the selected rows.</p>
  
  <p>I am trying to do this with this code:</p>
  
  <pre><code>function previewModal() {
    var sheet = SpreadsheetApp.getActiveSpreadsheet();
    var ranges =  sheet.getActiveRangeList().getRanges();
    var html = HtmlService.createHtmlOutput('');
    for (var i = 0; i &lt; ranges.length; i++) {
      var contentCell = ranges[i];        
      var htmlContent = contentCell.getValue();
      html.append('&lt;div&gt;').append(htmlContent).append('&lt;/div&gt;').append('&lt;hr&gt;');
    }
    html.setWidth(1000).setHeight(1000);
    SpreadsheetApp.getUi().showModalDialog(html, 'Preview');
  }
  </code></pre>
  
  <p>However, when I run this, I see that <code>ranges.length</code> is equal to 1, regardless of how many cells I have selected. And the cell that ranges contains is the "active" cell -> this is the one which you first clicked, before dragging across to cover more cells. As a result, my HTML output just contains the value from that 1 cell and not the range.</p>
  
  <p>What I mean by "Active Cell" and "Active Range":
  <a href="https://i.imgur.com/iPZdA36.png" rel="nofollow noreferrer"><img src="https://i.imgur.com/iPZdA36.png" alt=""></a></p>
  
  <h3>What I know so far:</h3>
  
  <ul>
  <li><code>sheet.getActiveRangeList()</code> works as intended and returns the entire "Active Range" of cells. I know this since I am able to call a <code>.clear</code> on this and see the selected range of cells clear out!</li>
  <li><code>sheet.getActiveRangeList().getRanges()</code> fails -> this is supposed to return an array of Range objects: <code>Range[]</code>, which it does, but the array only has the "Active Cell"</li>
  </ul>