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

LOOKUP does not handle Array form correctly #994

Closed
stanim opened this issue Aug 18, 2021 · 1 comment · Fixed by #996
Closed

LOOKUP does not handle Array form correctly #994

stanim opened this issue Aug 18, 2021 · 1 comment · Fixed by #996

Comments

@stanim
Copy link
Contributor

stanim commented Aug 18, 2021

Description

There are two ways to use LOOKUP: Vector form and Array form. For more info, see https://support.microsoft.com/en-us/office/lookup-function-446d94af-663b-451d-8251-369d5e3864cb

Excelize seems to support both, but the Array form does not work as expected. It returns the lookup value instead of the result

Steps to reproduce the issue:

  1. Add these two tests to calc_test.go, they should be equivalent and return the same result:
	mathCalc := map[string]string{
                ...
		"=LOOKUP(E3,E2:E5,F2:F5)":      "22100",
		"=LOOKUP(E3,E2:F5)":            "22100",

I've done this in my lookup-array-from branch: https://github.com/stanim/excelize/blob/lookup-array-form/calc_test.go#L1135

  1. Run go test.

Describe the results you received:

> go test
--- FAIL: TestCalcCellValue (7.87s)
    calc_test.go:1218: 
        	Error Trace:	calc_test.go:1218
        	Error:      	Not equal: 
        	            	expected: "22100"
        	            	actual  : "North 2"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1 +1 @@
        	            	-22100
        	            	+North 2
        	Test:       	TestCalcCellValue
        	Messages:   	=LOOKUP(E3,E2:F5)

Describe the results you expected:

I expected the tests to pass.

Output of go version:

go version go1.16.7 linux/amd64

Excelize version or commit ID:

> git log
commit a55f354eb3d0c6c1b9a543ff8ff98227aa6063a6 (HEAD -> lookup, origin/master, origin/HEAD, master)
Author: xuri <[email protected]>
Date:   Tue Aug 17 00:01:44 2021 +0800

    This closes #989, closes #990
    
    New API: `SetRowStyle` support for set style for the rows
    Update documentation for the `GetRows`, `SetCellStyle` and `SetColStyle`

Environment details (OS, Microsoft Excel™ version, physical, etc.):

  • OS: Archlinux 5.13.10-arch1-1
  • WPS Spreadsheets (version wps-office 11.1.0.10702-1)
  • LibreCalc (version libreoffice-fresh 7.1.5-2)
@stanim
Copy link
Contributor Author

stanim commented Aug 18, 2021

I've prepared a pull request #996 against the master branch to fix this issue.

How will this land in the v2 branch, which I use?

xuri added a commit to stanim/excelize that referenced this issue Aug 19, 2021
@xuri xuri closed this as completed in #996 Aug 19, 2021
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant