Skip to content

Do not correctly parse formula #578

@korvinko

Description

@korvinko

Description
Excelize do not correctly set formula on excelize v2.1.0 but this code below works on excelize v2.0.2. And as a result, I can see only one row but should see two rows

func main() {
	f := excelize.NewFile()
	sheet := "Sheet1"
	formula := `IF(AND( INDIRECT("G" & ROW())>0, INDIRECT("F" & ROW())>0 ), (INDIRECT("G" & ROW()) - INDIRECT("F" & ROW()))/7, 0)`

	_ = f.SetCellValue(sheet, "F1", 10)
	_ = f.SetCellValue(sheet, "G1", 100)
	_ = f.SetCellFormula(sheet, "H1", formula)

	_ = f.SetCellValue(sheet, "F2", 10)
	_ = f.SetCellValue(sheet, "G2", 100)
	_ = f.SetCellFormula(sheet, "H2", formula)


	file, err := ioutil.TempFile(os.TempDir(), "*.xlsx")
	if err != nil {
		fmt.Printf("%+v", err)
	}
	path := file.Name()

	err = f.SaveAs(path)
	if err != nil {
		fmt.Printf("%+v", err)
	}

	fmt.Println(path)
}

Steps to reproduce the issue:

  1. Use the example of code from the description
  2. Compile and see the result xls file

Describe the results you received:
Xls with 1 row

Describe the results you expected:
Xls with 2 row

Output of go version:
go version go1.13 linux/amd64

Excelize version or commit ID:
github.com/360EntSecGroup-Skylar/excelize/v2 v2.1.0

Environment details (OS, Microsoft Excel™ version, physical, etc.):
Linux localhost 4.15.0-76-generic #86-Ubuntu SMP x86_64 GNU/Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions