handsontable / hyperformula

HyperFormula is an open-source headless spreadsheet for business web apps. It comes with over 400 formulas, CRUD operations, undo-redo, clipboard support, and sorting.
https://hyperformula.handsontable.com/
Other
1.95k stars 108 forks source link

Support Array type #131

Closed wojciechczerniak closed 3 years ago

wojciechczerniak commented 4 years ago

Description

ODFF defines Inline Arrays, Excel has Array Formulas/Constants.

Values rules

Array constants can contain numbers, text, logical values (such as TRUE and FALSE), and error values such as #N/A. You can use numbers in integer, decimal, and scientific formats. If you include text, you need to surround it with quotation marks ("text”).

Array constants can't contain additional arrays, formulas, or functions. In other words, they can contain only text or numbers that are separated by commas or semicolons. Excel displays a warning message when you enter a formula such as {1,2,A1:D4} or {1,2,SUM(Q2:Z8)}. Also, numeric values can't contain percent signs, dollar signs, commas, or parentheses.

Examples

1 2
3 4

Naming Inline Arrays (Array Formulas/Constants)

This can be done with Named Expressions API #126

hf.addNamedExpression('Quater1', { reference: '={"January"; "February"; "March"}' })
hf.addNamedExpression('Quater2', { reference: '={"April"; "May"; "June"}' })

Rember to use it with = sign: =Quarter1. Otherwise Quarter1 should be parsed as text.

Evaluation

  1. Evaluation as an implicit intersection of the argument with the expression's evaluation position.
  2. Matrix evaluation.

SPILL Error

Until the blockage is removed. Then everything should be displayed as normal.

obraz

Links

ODFF: https://docs.oasis-open.org/office/OpenDocument/v1.3/csprd02/part4-formula/OpenDocument-v1.3-csprd02-part4-formula.html#__RefHeading__1017968_715980110 ODFF: https://docs.oasis-open.org/office/OpenDocument/v1.3/csprd02/part4-formula/OpenDocument-v1.3-csprd02-part4-formula.html#__RefHeading__1017908_715980110 ODFF: https://docs.oasis-open.org/office/OpenDocument/v1.3/csprd02/part4-formula/OpenDocument-v1.3-csprd02-part4-formula.html#__RefHeading__1017866_715980110 Array formulas: https://support.office.com/en-us/article/guidelines-and-examples-of-array-formulas-7d94a64e-3ff3-4686-9372-ecfd5caa57c7 Dynamic vs constant arrays: https://support.office.com/en-us/article/dynamic-array-formulas-vs-legacy-cse-array-formulas-ca421f1b-fbb2-4c99-9924-df571bd4f1b4 Using arrays: https://wiki.openoffice.org/wiki/Documentation/How_Tos/Using_Arrays

izulin commented 3 years ago

671 introduces arrays parsed in formulas

wojciechczerniak commented 3 years ago

@izulin Not the same. This task is about arrays defined in the standard: https://docs.oasis-open.org/office/OpenDocument/v1.3/csprd02/part4-formula/OpenDocument-v1.3-csprd02-part4-formula.html#__RefHeading__1017866_715980110

izulin commented 3 years ago

@izulin Not the same. This task is about arrays defined in the standard: https://docs.oasis-open.org/office/OpenDocument/v1.3/csprd02/part4-formula/OpenDocument-v1.3-csprd02-part4-formula.html#__RefHeading__1017866_715980110

Could you point to feature from the standard that is not implemented?

wojciechczerniak commented 3 years ago

AFAIK you can't just type in the formula: = {1} + {1;2;3|4;5;6} and get value {2;3;4|5;6;7} as described in the use cases.

The notation was removed?

izulin commented 3 years ago

You can with #671

What do you mean by removed?

wojciechczerniak commented 3 years ago

Ok, didn't noticed that. I've seen tests with that notation removed in previous PRs, like ={TRANSPOSE( ... )}.

If you say we're here then I will definitely check #671 and the spec more carefully again ❤️

izulin commented 3 years ago

Removal of old ={TRANSPOSE( ... )} was step towards supporting this (modern) array notation.

wojciechczerniak commented 3 years ago

Done with so many PR that I can't list them here. See changelog for v1.