Posts tagged with google-sheets-api

When I run an ads-script to call the app-script::spreadsheet API, I get the following error:

var sheet = SpreadsheetApp.openByUrl(SPREADSHEET_URL); var rangeValues = sheet.getRange(1, 1, sheet.getLastRow(), sheet.getLastColumn()).getValues(); ==> Cannot find method getRange(number,number,number,number) 

How can it be? Only a subset of the app-script sheet api is available from ads-script?

  1. When I run an ads-script to call the "spreadsheet" API. I want to enrich a sheet by duplicating some rows according to values I have in a script.

How should I do this effectively?

only by creating a new tab? Starting from the last row? As I change the range while iterating.

  for ( i = 0; i < lastColumn - 1; i++){     for ( j = 0 ; j < lastRow - 1; j++){       var kw_data = kw_to_label[rangeValues[j][i]];         if(kw_data != null){         sheet.getRange(j,i).setValue(kw_data.labels[k]);   

An example:

dict: k1 -> val1, val2 k2 -> val3 

and sheet:

I am currently trying to import latitude and longitude values from a sheet, into my Google ads campaign through a script that looks like this:

function main() {   var SPREADSHEET_URL = 'https://docs.google.com/spreadsheets/d/17w74flZ3AD7r7wIbAoYYkffUuJfxGB0-a9lhjBStzW4/edit#gid=0';   var spreadsheet = SpreadsheetApp.openByUrl(SPREADSHEET_URL);   var sheet = spreadsheet.getActiveSheet();   var data = sheet.getRange("A:E").getValues();   for (i in data) {     if (i == 0) {       continue;       }     var [CampaignName, latitude, longitude, radius, unit] = data[i];     if (CampaignName == "") {       break;     }     else {       var campaignIterator = AdWordsApp.campaigns()         .withCondition("CampaignName CONTAINS_IGNORE_CASE '" + CampaignName +"'")         .get();       while (campaignIterator.hasNext()) {         var campaign = campaignIterator.next();         campaign.addProximity(latitude, longitude, radius, unit);       }     }   } } 

However, when running the script, I keep getting the error "Invalid argument: latitude. Should be of type: number (file Code.gs, line 22)" What am I doing wrong? (also the sheet link is open for anyone, and its a back up so no worries).