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

A bug was found about the Max function. #1582

Closed
podmask opened this issue Jul 19, 2023 · 1 comment
Closed

A bug was found about the Max function. #1582

podmask opened this issue Jul 19, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@podmask
Copy link

podmask commented Jul 19, 2023

There is the code :

func TestMyTest(t *testing.T) {
	f, err := excelize.OpenFile("../test.xlsx")
	if err != nil {
		fmt.Println(err)
		return
	}
	defer f.Close()

	f.SetCellValue("sheet1", "A9", "ABC")
	f.SetCellValue("sheet1", "B10", "ABC")
	f.SetCellValue("sheet1", "B11", "ABC")
	f.SetCellValue("sheet1", "B12", "ABC")

	f.SetCellFormula("sheet2", "A10", `IF(B10<>"",MAX($A$9:A$9)+1,"")`)
	f.SetCellFormula("sheet2", "A11", `IF(B11<>"",MAX($A$9:A$10)+1,"")`)
	f.SetCellFormula("sheet2", "A12", `IF(B12<>"",MAX($A$9:A$11)+1,"")`)
	value, err := f.CalcCellValue("sheet1", "A10")
	if err != nil {
		fmt.Println(err)
		return
	}
	t.Log(value)
	value, err = f.CalcCellValue("sheet1", "A11")
	if err != nil {
		fmt.Println(err)
		return
	}
	t.Log(value)
	value, err = f.CalcCellValue("sheet1", "A12")
	if err != nil {
		fmt.Println(err)
		return
	}
	t.Log(value)
}

Output infomation:

Running tool: C:\golang\go\bin\go.exe test -timeout 30s -run ^TestMyTest$ excelizer/testing -v

=== RUN   TestMyTest
    d:\DEV\go-dev\excelizer\testing\excel_test.go:110: 1
    d:\DEV\go-dev\excelizer\testing\excel_test.go:116: 1
    d:\DEV\go-dev\excelizer\testing\excel_test.go:122: 1
--- PASS: TestMyTest (0.00s)
PASS
ok  	excelizer/testing	0.333s

The expect result is :

1
2
3

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

@xuri xuri added bug Something isn't working in progress Working in progress labels Jul 20, 2023
@xuri xuri closed this as completed in 8d996ca Jul 20, 2023
@xuri
Copy link
Member

xuri commented Jul 20, 2023

Thanks for your issue. I have fixed this issue, please try to upgrade the master branch code, and this patch will be released in the next version.

@xuri xuri removed the in progress Working in progress label Jul 20, 2023
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
…ves form controls

- Fix incorrect formula calculate results on a nested argument function which returns a numeric result
- Add a new exported error variable `ErrorFormControlValue`
- Rename exported enumeration `FormControlCheckbox` to `FormControlCheckBox`
- Rename exported enumeration `FormControlRadio` to `FormControlOptionButton`
- The `AddFormControl` function supports new 5 form controls: spin button, check box, group box, label, and scroll bar
- Update documentation for the `GraphicOptions` data type, `AddFormControl` and `NewStreamWriter` functions
- Update the unit tests
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
None yet
Development

No branches or pull requests

2 participants