title: Export Google Spreadsheet to .XLSX every time an edit is made
body: <p>I want a Google Script that automatically exports the Spreadsheet to a .XLSX whenever there is an edit made, overwriting any previous versions.  Using <a href="https://stackoverflow.com/questions/12712137/google-apps-script-to-email-google-spreadsheet-excel-version/12867942#12867942">this answer</a> as a template, I created the following code:</p>
  
  <pre class="lang-js prettyprint-override"><code>function onEdit() {
    var s = SpreadsheetApp.getActiveSheet();
    var r = s.getActiveCell();
    if( r.getColumn() != 1 ) { //checks the column
      var row = r.getRow();
      var time = new Date();
      time = Utilities.formatDate(time, "GMT-08:00 ", "MM/dd/yy, hh:mm:ss");
      SpreadsheetApp.getActiveSheet().getRange('A' + row.toString()).setValue(time); 
  
      var id = 'MY_SPREADSHEET_KEY'
      var url = 'https://docs.google.com/feeds/';
      var doc = UrlFetchApp.fetch(url+'download/spreadsheets/Export?key='+id+'&amp;exportFormat=xls',
                                  googleOAuth_('docs',url)).getBlob()
      DocsList.createFile(doc).rename('newfile.xls')
    };
   };
  
  function googleOAuth_(name,scope) {
    var oAuthConfig = UrlFetchApp.addOAuthService(name);
    oAuthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope="+scope);
    oAuthConfig.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken");
    oAuthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");
    oAuthConfig.setConsumerKey('anonymous');
    oAuthConfig.setConsumerSecret('anonymous');
    return {oAuthServiceName:name, oAuthUseToken:"always"};
  }
  </code></pre>
  
  <p>However, it doesn't seem to be exporting.  OR, if it is exporting, I'm not sure where this is happening.</p>
  
  <p>Any ideas?</p>