Skip to main content
Version: Streamsheets 2.5

ARRAY

This function can be used to efficiently add array items to a message. Creates a JSON array entry using the given keys and values. If the range has one row or column, one array entry for each cell is created. If there are two columns or rows, a nested array (array containing a subarray) will be created. Note that if both nest and flat parameters are set to true one can use range instead.

Syntax

=ARRAY(Range, [Nest], [Flat])

Arguments

NameDescription
RangeSource Range to retrieve data from
Nest (optional)Direction on how to nest items, if range has more than one row or column. FALSE to nest by column and TRUE to nest by row. Default is TRUE.
Flat (optional)If this Argument is supplied (any value works!) the returned Array is always nested, even if only one row or column is specified. If Argument is missing than the returned array is only nested if there are more than one row or column.

Return

Comma separated list of array items.

Examples

FormulaResultComment
=WRITE(OUTBOXDATA("Message", "NewItem"), ARRAY(A2:B5, FALSE), "Array") with the following cell content: 
Appending an array to a message.
Since Nest is set to FALSE, the array items are created by columns
leading to two array entries. The two entries contain
the elements from the rows top to bottom.
The message content will look as follows
=WRITE(OUTBOXDATA("Message","NewItem"),
ARRAY(A2:A5,FALSE),"Array") =WRITE(OUTBOXDATA("Message","NewItem2"),
ARRAY(B2:B5,FALSE,TRUE),"Array")
Example usage of the nested parameter.
tip

If you want to create an Outbox array step by step, you can use "-1" as last outbox data path to automatically add a new array element to the existing outbox message. =WRITE(OUTBOXDATA("Message";"data";-1);JSON(B1:C5);)