title: Need only some columns to be sent in mail with one more column sorting criteria
body: <p>I got a code with updated, need a table with few columns and some more criteria for sorting date. First Need to sort column X with TAT&gt;2, column B with banks, and only B,C,D,E,G,H,J,K,X columns need to be mailed. Kindly help me with it.</p>
  <pre><code>function createTable() {
    var sheet1 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(&quot;Sheet1&quot;);
    const dataRange = sheet1.getRange(&quot;A2:AH&quot;);
  
    var criterias = [&quot;Report Pending&quot;, &quot;Site Visit Pending&quot;, &quot;Query Raised&quot;]
    var backgrounds = dataRange.getBackgrounds(); // Added
    var data = dataRange.getDisplayValues(); // Modified
    var table = &quot;&lt;html&gt;&lt;body&gt;&lt;br&gt;&lt;table border=1&gt;&lt;tr&gt;&lt;th&gt;Compliance Score&lt;/th&gt;&lt;th&gt;STSOR Value&lt;/th&gt;&lt;th&gt;STSOR %&lt;/th&gt;&lt;th&gt;ZZ lines&lt;/th&gt;&lt;th&gt;ZZ%&lt;/th&gt;&lt;th&gt;PI lines Counted&lt;/th&gt;&lt;th&gt;PI %&lt;/th&gt;&lt;th&gt;NRDS Value&lt;/th&gt;&lt;th&gt;NRDS %&lt;/tr&gt;&lt;/br&gt;&quot;;
    for (var i = 0; i &lt; data.length; i++) {
      cells = data[i];
      if (cells[23] &gt; 2 &amp;&amp; criterias.indexOf(cells[9]) != -1) {
        table = table + &quot;&lt;tr&gt;&quot;;
        for (var u = 0; u &lt; cells.length; u++) {
          table = table + `&lt;td style=&quot;background-color:${backgrounds[i][u]}&quot;&gt;` + cells[u] + &quot;&lt;/td&gt;&quot;; // Modified
        }
        table = table + &quot;&lt;/tr&gt;&quot;
      }
    }
  
    //Send the email:
    MailApp.sendEmail({
      to: &quot;ramauni3994@gmail.com&quot;,
      subject: &quot;Example&quot;,
      htmlBody: table
    });
  }
  </code></pre>
  <p>Like this photo table need to be displayed.</p>
  <p><a href="https://i.stack.imgur.com/AnE07.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AnE07.png" alt="enter image description here" /></a></p>