0

I'm a beginner in programming, and I'm trying to print a nested array to a sheet. sourceData is an array that has 252 other arrays inside it and each one of these arrays has 10 element, so i want to print these 10 elements in 10 column (each element in its own cell) in one row 252 times. I tried doing that using a for loop but it was getting the first element only "370" in all the columns + in 502 rows and i feel like its very messy.

var y=0;
  for(let x=3; x<sourceData.length+3; x++){//   x is number of the row


  
  thisSheet.getRange(parseInt(x),1 ,sourceData.length,10).setValue(sourceData[y]);
  y++;
  }

If you need more information please let me know.

I have been stuck here for too long and would really appreciate the help.

Thank you.

Omar
  • 181
  • 2
  • 14

1 Answers1

3

You shouldn't need a loop.

Try

thisSheet.getRange(3, 1, sourceData.length, sourceData[0].length).setValues(sourceData)
James
  • 20,957
  • 5
  • 26
  • 41