Calc/Features/array constants in formulas

From Apache OpenOffice Wiki
< Calc‎ | Features
Jump to: navigation, search

Array constants are implemented with i32342 in CWS jgarrays

Description

Calc now supports inline matrix/array constants in formulas. An inline array is surrounded by curly braces '{' and '}'. Elements can be each a number (including negatives), a logical constant (TRUE, FALSE) or a literal string. Non-constant expressions are not allowed. Arrays can be entered with one or more rows, and one or more columns. All rows must consist of the same number of elements, all columns must consist of the same number of elements, so that a two-dimensional array has no sparse elements. The column separator (separating elements in one row) is the ';' semicolon, the row separator is a '|' pipe symbol. They were chosen because the upcoming ODF formula specification uses these separators. Contrary to Excel, the separators are not UI-version and/or locale dependent. Arrays can not be nested. Import/export from/to Excel are implemented.

Examples

={1;2;3} 
An array with one row consisting of the three numbers 1, 2 and 3.
={1;2;3|4;5;6} 
An array with two rows and three values in each row.
={0;1;2|FALSE;TRUE;"two"} 
A mixed data array.
=SIN({1;2;3}) 
Entered as a matrix formula delivers the result of three SIN calculations with the arguments 1, 2 respectively three.
={1;2|4;5;6} 
Invalid array, the first row misses an element. This results in Err:512 "Formula overflow".
={1;2+3} 
Invalid array, the second element is not a constant. This results in Err:512 "Formula overflow".
={1;2;{3;4;5}} 
Invalid array, nested arrays are not allowed. This results in Err:533 "Nested arrays are not supported". This is a new error condition relevant for translation.
Personal tools