Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

303
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!