Home > database >  Write multiple rows on Google Sheet (at once) with data from a dictionary (using Apps Script)
Write multiple rows on Google Sheet (at once) with data from a dictionary (using Apps Script)

Time:05-27

On app script, I have a dictionary object with the format: { name1: "info1", name2: "info2", … }.

Screenshot of the sheet for reference: enter image description here

CodePudding user response:

Does this help?

  const dict = ...
  const data = Object.keys(dict).map(key => [key, dict[key]])
  
  SpreadsheetApp.getActiveSpreadsheet()
                .getSheetByName(`MY_SHEET`)
                .getRange(2, 1, data.length, data[0].length)
                .setValues(data)
  • Related