Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

60
Views
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.

Thank you.

7 months ago · Juan Pablo Isaza
1 answers
Answer question

0

You shouldn't need a loop.

Try

thisSheet.getRange(3, 1, sourceData.length, sourceData[0].length).setValues(sourceData)
7 months ago · Juan Pablo Isaza Report
Answer question
Find remote jobs