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"
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"
Share Improve this question edited Jan 20, 2019 at 1:48 Wicket 38.7k9 gold badges80 silver badges194 bronze badges asked Sep 22, 2017 at 21:44 Vedrit MathiasVedrit Mathias 511 silver badge2 bronze badges2 Answers
Reset to default 6 +250Assuming 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;
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
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744201313a4562891.html
评论列表(0条)