Skip to content

Eager evaluation of function arguments doesn't work with LOOKUP functions #2070

@xaoctech

Description

@xaoctech

Description

It seems excelize evaluates all function arguments before calling a function, which doesn't work well with LOOKUP (HLOOKUP, VLOOKUP ...) functions, especially if table range is large.

E.g. =VLOOKUP(C1, A:XFD, 2) will try to calculate all the cells in the table, instead of just lazily calculating cells in A column, and then calculate a corresponding single cell from B column.

Steps to reproduce the issue

  1. Add this simple table to the project
    vlookup.xlsx

  2. Run this code

package main

import (
	"fmt"
	"github.com/xuri/excelize/v2"
)

func unwrap[T any](v T, err error) T {
	if err != nil {
		panic(err)
	}
	return v
}

func main() {
	file := unwrap(excelize.OpenFile("vlookup.xlsx"))
	val := unwrap(file.CalcCellValue("Sheet1", "C2"))
	fmt.Println(val)
}

Describe the results you received

It takes ages to calculate this field value.

Describe the results you expected

It should be instant to calculate this cell value.

Go version

1.23.4

Excelize version or commit ID

2.9.0

Environment

Windows 11

Validations

  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions