title: Google Spreadsheet API returning grid limits error
body: <p>I am trying to update a Google Sheet using the Ruby API (that is just a wrapper around the SheetsV4 API)</p>
  
  <p>I am running into the following error</p>
  
  <blockquote>
    <p>Google::Apis::ClientError: badRequest: Range ('MySheet'!AA1) exceeds grid limits. Max rows: 1000, max columns: 26</p>
  </blockquote>
  
  <p>I have found references of this problem <a href="https://groups.google.com/forum/#!topic/google-spreadsheets-api/7fbHUmY3Tt4" rel="nofollow noreferrer">on the google forum</a>, however there did not seem to be a solution to the problem other that to use a different method to write to the spreadsheet.</p>
  
  <p>The thing is, I need to copy an existing spreadsheet template, and enter my raw data in various sheets. So far I have been using this code (where <code>service</code> is a client of the Ruby SheetsV4 API)</p>
  
  <pre><code>def write_table(values, sheet: 'Sheet1', column: 1, row: 1, range: nil, value_input_option: 'RAW')
    google_range = begin
      if range
        "#{sheet}!#{range}"
      elsif column &amp;&amp; row
        "#{sheet}!#{integer_to_A1_notation(column)}#{row}"
      end
    end
    value_range_object = ::Google::Apis::SheetsV4::ValueRange.new(
      range: google_range, values: values
    )
    service.update_spreadsheet_value(spreadsheet_id,
      google_range,
      value_range_object,
      value_input_option: value_input_option
    )
  end
  </code></pre>
  
  <p>It was working quite well so far, but after adding more data to my extracts, I went over the 26th column, (columns <code>AA</code> onwards) and now I am getting the error.</p>
  
  <p>Is there some option to pass to <code>update_spreadsheet_value</code> so we can raise this limit ?</p>
  
  <p>Otherwise, what is the other way to write to the spreadsheet using append ?</p>
  
  <p>EDIT - A clear description of my scenario</p>
  
  <p>I have a template Google spreadsheet with 8 sheets(tabs), 4 of which are titled <code>RAW-XX</code> and this is where I try to update my data.</p>
  
  <p>At the beginning, those raw tabs only have headers on 30 columns (A1 --> AD1)
  My code needs to be able to fill all the cells A2 --> AD42</p>
  
  <ul>
  <li>(1) for the first time</li>
  <li>(2) and my code needs to be able to re-run again to replace those values by fresh ones, without appending</li>
  </ul>
  
  <p>So basically I was thinking of using <code>update_spreadsheet_value</code> rather than <code>append_xx</code> because of the requirement (2). But becuase of this bug/limitation (unclear) in the API, this does not work. ALso important to note : I am not actually updating all those 30 columns in one go, but actually in several calls to the <code>update</code> method (with up to 10 columns each time)</p>
  
  <p>I've thought that
  - Maybe I am missing an option to send to the Google API to allow more than 26 columns in one go ?
  - Maybe this is actually an undocumented hard limitation of the <code>update</code> API
  - Maybe I can resort to deleting existing data + using append</p>
  
  <p>EDIT 2</p>
  
  <p>Suppose I have a template at version 1 with multiple sheets (Note that I am using <code>=xx</code> to indicate a formula, and <code>[empty]</code> to indicate there is nothing in the cell, and <code>1</code> to indicate the raw value "1" was supplied</p>
  
  <pre><code>Sheet1 - RAW
  RAW Number of foos | RAW Number of Bars |
  [empty]            | [empty]            |
  
  Sheet2 - FORMATTED
  Number of foos       | Number of Bars
  ='Sheet1 - RAW'!A2   | ='Sheet1 - RAW'B2
  </code></pre>
  
  <p>Now I call my app "for the first time", this copies the existing template to a new file "generated_spreadsheet" and injects data in the RAW sheet. It turns out at this moment, my app says there is 1 foo and 0 bar</p>
  
  <pre><code>Sheet1 - RAW
  RAW Number of foos | RAW Number of Bars |
  1                  | 0                  |
  
  Sheet2 - FORMATTED
  Number of foos       | Number of Bars
  ='Sheet1 - RAW'!A2   | ='Sheet1 - RAW'!B2
  </code></pre>
  
  <p>Maybe if I call my app later, maybe the template AND the data have changed in between, so I want to REPLACE everything in my "generated_spreadsheet"</p>
  
  <p>The new template has become in between</p>
  
  <pre><code>Sheet1 - RAW
  RAW Number of foos | RAW Number of Bars |
  [empty]            | [empty]            |
  
  Sheet2 - FORMATTED
  Number of foos       | Number of Bars     | All items
  ='Sheet1 - RAW'!A2   | ='Sheet1 - RAW'!B2 | =A2 + B2
  </code></pre>
  
  <p>Suppose now my app says there is still 1 foo and the number of bars went from 0 to 2, I want to update the "generated_spreadsheet" so it looks like</p>
  
  <pre><code>Sheet1 - RAW
  RAW Number of foos | RAW Number of Bars |
  1                  | 3                  |
  
  Sheet2 - FORMATTED
  Number of foos       | Number of Bars     | All items
  ='Sheet1 - RAW'!A2   | ='Sheet1 - RAW'!B2 | =A2 + B2
  </code></pre>