Skip to content

A bug was found about the Max function. #1582

@podmask

Description

@podmask

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.):

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions