Apps Script Help?

function doGet(e) {

  var sheet = SpreadsheetApp.getActive();

  var nse = sheet.getSheetByName("NSE");

  var data = [];

  var rlen = nse.getLastRow();

  var clen = nse.getLastColumn();

  var rows = rse.getRange(1,1,rlen,clen).getValues();

  for(var i = 0; i < rows.length ; i++){

    var datarow = rows[i];

    var record = {};

    for(var j=1; j < clen ; j++){

      record [rows[0][j]] = datarow[j];

    }

    data.push(record);

  }

  console.log(data);

  var result = JSON.stringify(data)

  return ConferenceService.createTextOuput(result).setMineType(ContenteService.setMineType.JSON);

}

This is the App Inventor community amd not an Apps Script community. .

Also you forgot to add some context...

Taifun

1 Like

Possibly forgot semicolon (;) ?

Last row of script is incorrect.

try:
return ContentService.createTextOutput(result);

You could probably achieve the same with a single web call, exporting the sheet to csv, e.g.
https://docs.google.com/spreadsheets/d/1TXdSGG8_EnCuQITDXCAeAoWiPb9QJaj_q6yPZb-Zw9k/export?format=csv?gid=0

function doGet(e) {
  var sheet = SpreadsheetApp.getActive();
  var nse = sheet.getSheetByName("name sheet");
  var data = [];
  var rlen = nse.getLastRow();
  var clen = nse.getLastColumn();
  var rows = rse.getRange(1,1,rlen,clen).getValues();
  for(var i = 0; i < rows.length ; i++){
    var datarow = rows[i];
    var record = {};
    for(var j=1; j < clen ; j++){
      record [rows[0][j]] = datarow[j];
    }
    data.push(record);
  }
  console.log(data);
  var result = JSON.stringify(data)
  return ContentService.createTextOutput(result);
}

Can you show me how it performed? mine is still giving error

And that error message is?

Erro

ReferenceError: rse is not defined

doGet

@ Código.gs:7

Look at your code on line 7. rse should be nse.