Reputation: 51
I'm writing a script for use in Google Sheets where it returns an array of arrays for the purpose of filling out multiple columns and rows.
I've got
var results = new Array(2);
var info = new Array(2);
info[0] = "some string";
info[1] = "other string";
results[0] = info;
results[1] = info;
return results;
The first column will be blank when it should have "some string", while the second contains "other string"
Upvotes: 4
Views: 4909
Reputation: 11
var results = new Array(2);
var info = new Array(2);
info[0] = "some string";
info[1] = "other string";
results[0] = info;
return results;
I tried your code on multiple rows containing data but got error that Google Sheet can't write as it will overwrite next line.
I made changes to first line then it worked
var results = new Array(1);
var info = new Array(2);
info[0] = "some string";
info[1] = "other string";
results[0] = info;
return results;
Thank You. Snapshot of code used in actual project
Upvotes: 1
Reputation: 5043
Assuming that you are asking about Custom Functions in Google Spreadsheets, your code currently returns a 2x2 table with the values:
|----------------------------|
| some string | other string |
| some string | other string |
|----------------------------|
If you want the following:
|----------------------------|
| some string | other string |
|----------------------------|
Then your code should be:
var results = new Array(2);
var info = new Array(2);
info[0] = "some string";
info[1] = "other string";
results[0] = info;
return results;
Upvotes: 6