KrissyG
KrissyG

Reputation: 3

How do I split up a row array in GAS?

I have an array which is in range E10:O10 and when I enter the following script:

var array1 = ss.getRange('E10:O10').getValues();
Logger.log(array1)
for (var i in array1)
{
panel.add(app.createLabel(array1), 10, 12);  
//Can I do something with array1.length + '' in here to split the values?
}

The array comes up with commas between them. Is there any way to split them up and define the pixel width or do you need to use array1.length?

Upvotes: 0

Views: 66

Answers (1)

ScampMichael
ScampMichael

Reputation: 3728

Arrays retrieved with getValues are two dimensions even when only one row is extracted. Something like:

var array1 = ss.getRange('E10:O10').getValues();
Logger.log(array1)
for (var i = 0; i < array1[0].length; i++ )
{
panel.add(app.createLabel(array1[0][i], 10, 12);  
}

Upvotes: 2

Related Questions