Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to print a nested Array to an excel sheet

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thank you.

>Solution :

You shouldn’t need a loop.

Try

thisSheet.getRange(3, 1, sourceData.length, sourceData[0].length).setValues(sourceData)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading