Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

310
Vistas
Writing data in spreadsheet in google app script

I'm trying to write a map(key, value) pair to google sheets using app script. I have tried using the method below

var crNew = SpreadsheetApp.create("newWorksheetName",1,1);
var ssNew = SpreadsheetApp.openByUrl(crNew.getUrl());

var x=ssNew.getRange("A1");
x.setValues(apimap.keys,apimap.values);

but I'm getting an error as follows

Exception: The parameters (String,String) don't match the method signature for SpreadsheetApp.Range.setValues. myfunction @ Code.gs:102

Can anyone please tell that where i'm doing wrong.The line 102 is this one x.setValues(apimap.keys,apimap.values);

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You are trying to call setValues method with 2 arguments.

Based on documentation this method waits for a two-dimensional array of values as an argument: enter image description here

about 4 years ago · Juan Pablo Isaza Denunciar

0

I have achieved my task as follows (posting it here in case someone faces it in future):

   var crNew = SpreadsheetApp.create("newWorksheetName",1,1);
    var ssNew = SpreadsheetApp.openByUrl(crNew.getUrl());
   
    
    var a=[];
    apimap.forEach (function(value, key) {    //apimap is my map containing data
      a.push([key,value]);    //i pushed data map into an array
    })
    var x=ssNew.getSheetByName("Sheet1").getRange(1,1,a.length,a[0].length);
    x.setValues(a);

This automatically writes keys in one column and values in the adjacent column

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda