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

Found a defect in the FIND function during the process of multi-value query. #1819

Closed
podmask opened this issue Feb 21, 2024 · 5 comments · Fixed by #1829
Closed

Found a defect in the FIND function during the process of multi-value query. #1819

podmask opened this issue Feb 21, 2024 · 5 comments · Fixed by #1829
Labels
bug Something isn't working

Comments

@podmask
Copy link

podmask commented Feb 21, 2024

Description

func TestMyTest(t *testing.T) {
	f, err := excelize.OpenFile("../test.xlsx")
	if err != nil {
		fmt.Println(err)
		return
	}
	defer f.Close()
	f.SetCellValue("sheet1", "D2", "张三")
	f.SetCellFormula("sheet1", "B2", `OR(ISNUMBER(FIND({"王五","李四","张三","陈七","刘大"},D2)))`)
	value, err := f.CalcCellValue("sheet1", "B2")
	if err != nil {
		fmt.Println("ERROR:", err)
		return
	}
	t.Log("value is:", value)
}

Steps to reproduce the issue:

  1. Run this test.

Describe the results you received:

=== RUN   TestMyTest
    d:\DEV\go-dev\excelizer\testing\excel_test.go:99: value is: FALSE
--- PASS: TestMyTest (0.01s)
PASS
ok  	excelizer/testing	0.271s

Describe the results you expected:

=== RUN   TestMyTest
    d:\DEV\go-dev\excelizer\testing\excel_test.go:99: value is: TRUE
--- PASS: TestMyTest (0.01s)
PASS
ok  	excelizer/testing	0.271s

Output of go version:

(paste your output here)

Excelize version or commit ID:
WPS

(paste here)

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

@xuri xuri added the confirmed This issue can be reproduced label Feb 22, 2024
@xuri xuri added bug Something isn't working in progress Working in progress and removed confirmed This issue can be reproduced labels Feb 24, 2024
@xuri xuri closed this as completed in 688808b Feb 25, 2024
@xuri
Copy link
Member

xuri commented Feb 25, 2024

Thanks for your issue. I have fixed this, and this patch has been released on v2.8.1, please upgrade to the lasted version.

@xuri xuri removed the in progress Working in progress label Feb 25, 2024
@podmask
Copy link
Author

podmask commented Feb 27, 2024

Thank you for your attention to this issue. I have updated to version v2.8.1 following your guidance, but the result of the unit test is still "FALSE". Could you please confirm if your test environment has passed this test?

@xuri xuri reopened this Feb 28, 2024
YueChenXu-Kimi added a commit to YueChenXu-Kimi/excelize that referenced this issue Feb 28, 2024
…R, OR and FIND support matrix arguments
@xuri xuri linked a pull request Feb 28, 2024 that will close this issue
10 tasks
xuri pushed a commit that referenced this issue Feb 29, 2024
…ND support matrix arguments (#1829)

- Keep minimum column and row number in formula operand when deleting columns and rows
- Update unit tests
@xuri
Copy link
Member

xuri commented Feb 29, 2024

Thanks for your feedback. This issue has been fixed. Please try to upgrade to the master branch code by go get -u github.com/xuri/excelize/v2@master, and this patch will be released in the next version.

@podmask
Copy link
Author

podmask commented Feb 29, 2024

Thank you very much for fixing this bug. In the latest master version, the above issue returns the correct result; however, the code still does not work properly under the following circumstances:

func TestMyTest(t *testing.T) {
f, err := excelize.OpenFile("../test.xlsx")
if err != nil {
fmt.Println(err)
return
}
defer f.Close()
f.SetCellValue("sheet1", "D2", "张三丰")
f.SetCellFormula("sheet1", "B2", IF(ISNUMBER(FIND({"王五","李四","张三","陈七","刘大"},D2)),"TRUE","FALSE"))
value, err := f.CalcCellValue("sheet1", "B2")
if err != nil {
fmt.Println("ERROR:", err)
return
}
t.Log("value is:", value)
}

the results I received:
`
Running tool: D:\golang\go\bin\go.exe test -timeout 30s -run ^TestMyTest$ excelizer/testing -v

=== RUN TestMyTest
d:\DEV\excelizer\testing\excel_test.go:99: value is: FALSE
--- PASS: TestMyTest (0.01s)
PASS
ok excelizer/testing
`

the results I expected:
`
Running tool: D:\golang\go\bin\go.exe test -timeout 30s -run ^TestMyTest$ excelizer/testing -v

=== RUN TestMyTest
d:\DEV\excelizer\testing\excel_test.go:99: value is: TRUE
--- PASS: TestMyTest (0.01s)
PASS
ok excelizer/testing
`

@xuri
Copy link
Member

xuri commented Mar 11, 2024

Thanks for your feedback. Could you provide the test.xlsx in your example? I created a new workbook instead of opening an existing workbook name. Because the value 张三丰 was not in the FIND formula's first argument array, the result of the ISNUMBER function should be FALSE. So, the calculated result is expected, which be the same as the calculated result in the spreadsheet app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Status: Bugfix
Development

Successfully merging a pull request may close this issue.

2 participants