title: Get Table Cell Values Google Docs
body: <p>We have a Google Document with a Table init, where we need to get the values inside the table cells into an Array. The table looks like this in Google Doc:
  <a href="https://i.stack.imgur.com/K3Sob.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/K3Sob.png" alt="enter image description here"></a></p>
  
  <p>I found a way to logg the values in the cells with this code:</p>
  
  <pre><code> var searchElement = copyBody.findElement(DocumentApp.ElementType.TABLE);
       var element = searchElement.getElement();
       var table = element.asTable();
       var tablerows = element.getNumRows();
  
          for ( var row = 0; row &lt; tablerows; ++row ) {
            var tablerow = element.getRow(row)
            for ( var cell=0; cell &lt; tablerow.getNumCells(); ++cell) {
  
  
              var celltext = tablerow.getChild(cell).getText();
             Logger.log( "Text is ("+celltext+")" );
  
            }
          }
  </code></pre>
  
  <p>How can we get these into an array that looks something like this:</p>
  
  <pre><code>   ['A', 'C', 'E', 'X'],
     ['Row 2, Cell 1 value', 'Row 2, Cell 2 value', 'Row 2, Cell 3 value', 'Row 2, Cell 4 value'],
     ['Row 3, Cell 1 value', 'Row 3, Cell 2 value', 'Row 3, Cell 3 value', 'Row 3, Cell 4 value']
  </code></pre>