#2416·excelize

VALUE of an empty cell returns #VALUE! instead of 0

Author: PhilflowIOCreated Sep 20, 2026Updated Sep 20, 2026

Description

VALUE takes the text of its argument straight away (calc.go:14956) without looking at the argument type. An empty cell yields the same empty text as an empty string, so both end up in the number parsing and both return #VALUE!.

An empty cell reads as 0 in a numeric context, so =VALUE(A1)+5 should be 5. An empty string holds no number and has to stay an error, the same way =VALUE(" ") is an error. The two are distinguishable: an empty cell arrives as ArgEmpty, an empty string as ArgString.

A range argument is not unwrapped either, so =VALUE(A1:A1) fails as well.

Steps to reproduce the issue

go
package main

import (
	"fmt"

	"github.com/xuri/excelize/v2"
)

func main() {
	f := excelize.NewFile()
	// A1 is never written, B1 yields an empty string, C1 holds a single space
	f.SetCellFormula("Sheet1", "B1", `=""`)
	f.SetCellValue("Sheet1", "C1", " ")
	for _, formula := range []string{
		`=VALUE(A1)`,
		`=VALUE(A1)+5`,
		`=VALUE(A1:A1)`,
		`=VALUE("")`,
		`=VALUE(B1)`,
		`=VALUE(C1)`,
	} {
		f.SetCellFormula("Sheet1", "E1", formula)
		result, err := f.CalcCellValue("Sheet1", "E1")
		fmt.Printf("%-16s %-10q %v\n", formula, result, err)
	}
}

Describe the results you received

=VALUE(A1)       "#VALUE!"  #VALUE!
=VALUE(A1)+5     "#VALUE!"  #VALUE!
=VALUE(A1:A1)    "#VALUE!"  #VALUE!
=VALUE("")       "#VALUE!"  #VALUE!
=VALUE(B1)       "#VALUE!"  #VALUE!
=VALUE(C1)       "#VALUE!"  #VALUE!

Describe the results you expected

=VALUE(A1)       "0"        <nil>
=VALUE(A1)+5     "5"        <nil>
=VALUE(A1:A1)    "0"        <nil>
=VALUE("")       "#VALUE!"  #VALUE!
=VALUE(B1)       "#VALUE!"  #VALUE!
=VALUE(C1)       "#VALUE!"  #VALUE!

The last three are unchanged.

Go version

go version go1.26.8 linux/amd64

Excelize version or commit ID

0434413

Environment

GOOS='linux'
GOARCH='amd64'
CGO_ENABLED='1'
GOVERSION='go1.26.8'