Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Sheets return multiple columns

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"

like image 455
Vedrit Mathias Avatar asked Oct 16 '25 15:10

Vedrit Mathias


1 Answers

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;
like image 154
Motin Avatar answered Oct 18 '25 05:10

Motin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!