Skip to content

Array instead of scalar result returned #4557

@SlowFox71

Description

@SlowFox71

It took me a while to break down understand what is happening here and I hope I got it correctly. If an Excel contains a formula with certain array functions, e.g. MIN(FILTER(HSTACK(A2), HSTACK(A2)<>0,0)) the result will look like

<f t="array" ref="A1">MIN(_xlfn._xlws.FILTER(_xlfn.HSTACK(A2), _xlfn.HSTACK(A2)<>0,0))</f>

I don't understand the idea of the array attribute here since MIN returns a scalar. But it is there and this is a problem, because of this piece of code in Cell/Cell.php

 if (
     !is_array($result)
     && $calculation->getInstanceArrayReturnType() === Calculation::RETURN_ARRAY_AS_ARRAY
     && $oldAttributesT === 'array'
     && ($oldAttributesRef === $coordinate || $oldAttributesRef === "$coordinate:$coordinate")
 ) {
     $result = [$result];
 }

At least in this case the conversion from scalar to array is wrong. The excel file used to recreate the XML is attached.

test.xlsx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions