I\'m trying to use HTTP Get
in Google Spreadsheet, to be able to create a URL
to a specific cell in a sheet.
I\'ve been searching for how to
The url you show is not valid.
To use that kind of script you have to deploy the script as a webapp and use the resulting .exec url with parameters.
At the end it will look like this :
https://script.google.com/macros/s/AKfycbygwUwXXXXXXXXxJcKpBvsbflmnZ0Uqfu-JISWTZNvar32s3v_hl/exec?row=5&col=1
EDIT : there will be no activeSheet in that context, use openById
or openByUrl
instead.
Also the values you get for row and columns are strings, you should make them integers and use a normal sheet.getRange(row,col)
to select a range.
EDIT2 :
this url :
https://script.google.com/macros/s/AKfycbwZbGW6E483BUplvLjCjNCXKjjiRorqzR9lruSydogeuU-YIvID/exec?row=1&col=1
and this code :
function doGet(e){
var ss = SpreadsheetApp.openById("1sbJXuEpL_88-u-Bm4QOCAM3SVddFwZKI0c1kxeRpcos");
var sheet = ss.getSheetByName("Sheet1");
var row = Number(e.parameter.row);
var col = Number(e.parameter.col);
var range = sheet.getRange(row, col);
sheet.getRange(row, col).setValue('test ok')
}
writes in this sheet : see cell A1 or test on another row and column.
You'll indeed receive a message that nothing was returned and this is actually true ! we don't return anything in that code, this is just a demo ;-)
EDIT 3 : as mentioned in the comments, to get something returned by this function you have to resturn something...
Here is an example :
function doGet(e){
var ss = SpreadsheetApp.openById("1sbJXuEpL_88-u-Bm4QOCAM3SVddFwZKI0c1kxeRpcos");
var sheet = ss.getSheetByName("Sheet1");
var row = Number(e.parameter.row);
var col = Number(e.parameter.col);
var range = sheet.getRange(row, col);
var value = sheet.getRange(row, col).getValue();
sheet.getRange(row, col).setValue('test ok');
var stringValue = value==''?'empty':value;
Logger.log(stringValue);
return ContentService.createTextOutput(stringValue).setMimeType(ContentService.MimeType.TEXT);
}