Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to calculate INDEX() function #64

Closed
balgf opened this issue Jan 2, 2017 · 7 comments · Fixed by #4088
Closed

Fails to calculate INDEX() function #64

balgf opened this issue Jan 2, 2017 · 7 comments · Fixed by #4088

Comments

@balgf
Copy link

balgf commented Jan 2, 2017

Sample formula:
=INDEX({"First","Second","Third","Fourth","Fifth","Sixth","Seventh"}, 4)

Errors thrown:
Undefined offset: 3 in /var/www/html/hoosh/excel_v2/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef.php on line 603
Undefined index: in /var/www/html/hoosh/excel_v2/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef.php on line 610

@balgf
Copy link
Author

balgf commented Jan 2, 2017

Turns out, $arrayValues passed to INDEX method is a 2 level array which is causing the issue.

array (size=1)
  0 => 
    array (size=7)
      0 => string 'First' (length=5)
      1 => string 'Second' (length=6)
      2 => string 'Third' (length=5)
      3 => string 'Fourth' (length=6)
      4 => string 'Fifth' (length=5)
      5 => string 'Sixth' (length=5)
      6 => string 'Seventh' (length=7)

@PowerKiKi
Copy link
Member

You are probably experiencing the same issue as PHPOffice/PHPExcel#1091. If you are able to provide a PR to solve it, that would very much appreciated.

@balgf
Copy link
Author

balgf commented Jan 5, 2017

It's different from that issue. I'll submit a report for that one coz it's still occurring in this package. Then, i'll drop a PR for fix on both issues.

balgf added a commit to balgf/PhpSpreadsheet that referenced this issue Jan 7, 2017
@balgf
Copy link
Author

balgf commented Jan 7, 2017

There appears to be a breakage when I pulled the latest dev copy. Not sure which commit caused this. Now the $arrayValues only recieved the last element. My fix no longer works because of this.

array (size=1)
  0 => string 'Seventh' (length=7)

@ankitm123
Copy link
Contributor

ankitm123 commented Mar 6, 2017

I will take a look, and understand the issue, and see if I can fix it

@stale
Copy link

stale bot commented Dec 4, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this is still an issue for you, please try to help by debugging it further and sharing your results.
Thank you for your contributions.

@stale stale bot added the stale label Dec 4, 2017
@stale stale bot closed this as completed Dec 11, 2017
@oleibman
Copy link
Collaborator

oleibman commented Jul 6, 2024

Probably the oldest bug I've worked on on this project. Fix will be available in a day or two.

@oleibman oleibman reopened this Jul 6, 2024
@stale stale bot removed the stale label Jul 6, 2024
@oleibman oleibman mentioned this issue Jul 6, 2024
11 tasks
github-merge-queue bot pushed a commit that referenced this issue Jul 12, 2024
Fix #64 (really!), closed as stale in December 2017, another in our "better late than never" series. Excel's INDEX function doesn't really behave quite as described. If a single row is used as an argument, either in literal form `{item1, item2, item3}` or expressed as a range `A1:A6`, INDEX is happy to evaluate the array as if each entry were a row rather than a single item. PhpSpreadsheet is changed to do likewise.

INDEX also returned `#REF!` when it would normally return an array (which would often be reduced to its leftmost topmost entry later). This code is deleted, invalidating one existing test, and INDEX will now operate like other functions which can return arrays.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

4 participants