title: Insert row and preserve formulas on Google Spreadsheet
body: <p>I'm making a spreadsheet that updates itself daily. For simplicity, let's say I generate a number every noon, and at night the spreadsheet is supposed to copy the number into a log column, and show the sum of all stored values for this column (there are actually several columns, and their number might grow in the future). With my current implementation, the sum formula is updated automatically, and thus keeps saving only the values previously available. I wish I could prevent this behavior.</p>
  
  <p>Example:</p>
  
  <p>The spreadsheet reads:</p>
  
  <pre><code>Total     1
  Today     2
  History 
  1/29/2014 1
  </code></pre>
  
  <p>Tomorrow, before I update it, it should be:</p>
  
  <pre><code>Total     3
  Today     
  History 
  1/30/2014 2
  1/29/2014 1
  </code></pre>
  
  <p>The formula I inserted on "Total" line is: </p>
  
  <pre><code>=sum(B4:B)
  </code></pre>
  
  <p>Basically, the code I've made for the script contains:</p>
  
  <pre><code>//Inserts a new line to compose history log:
  sheet.insertRowsAfter(firstHystoryLine-1, 1);
  </code></pre>
  
  <p>And after the script is run, the formula is updated to </p>
  
  <pre><code>=sum(B5:B)
  </code></pre>
  
  <p>Therefore my problem.</p>