qax-os/excelize · error

#NAME?

#NAME?

Error message

#NAME?

What it means

Excelize's formula engine emits the #NAME? error when it cannot resolve a token in a formula as a known function. During infix evaluation, evalInfixExpFunc looks up the token in the registered function table; if the name is unknown, misspelled, unsupported, or the token sequence is not a valid function call, it returns a formulaArg of Type ArgError carrying formulaErrorNAME, which propagates out of CalcCellValue. This mirrors Excel's #NAME? for unrecognized identifiers.

Source

Thrown at calc.go:1146

				continue
			}

			if inArrayRow && isOperand(token) {
				formulaArrayRow = append(formulaArrayRow, opfdStack.Pop().(formulaArg))
				continue
			}
			if inArrayRow && isFunctionStopToken(token) {
				formulaArray = append(formulaArray, formulaArrayRow)
				inArrayRow = false
				continue
			}
			if inArray && isFunctionStopToken(token) {
				argsStack.Peek().(*list.List).PushBack(newMatrixFormulaArg(formulaArray))
				inArray = false
				continue
			}
			if errArg := f.evalInfixExpFunc(ctx, sheet, cell, token, nextToken, opfStack, opdStack, opftStack, opfdStack, argsStack); errArg.Type == ArgError {
				return errArg, errors.New(errArg.Error)
			}
		}
	}
	for optStack.Len() != 0 {
		topOpt := optStack.Peek().(efp.Token)
		if err = calculate(opdStack, topOpt); err != nil {
			return newErrorFormulaArg(err.Error(), err.Error()), err
		}
		optStack.Pop()
	}
	if opdStack.Len() == 0 {
		return newEmptyFormulaArg(), ErrInvalidFormula
	}
	if result := opdStack.Peek().(formulaArg); result.Type == ArgError {
		return result, errors.New(result.Error)
	}
	return opdStack.Peek().(formulaArg), err
}

View on GitHub (pinned to f2483381fb)

Solutions

  1. Check the formula text in the cell and fix the function name spelling against the list of functions supported by your Excelize version.
  2. Upgrade github.com/xuri/excelize to the latest version, as new formula functions are added regularly.
  3. Replace unsupported/custom functions with an equivalent supported function, or compute the value in Go and write the result instead of a formula.
  4. Check the error string returned alongside #NAME? (e.g. 'invalid reference') for the specific sub-cause.

Example fix

// before: cell contains "=ABS(~+1)" -> CalcCellValue returns "#NAME?"
cellVal, err := f.CalcCellValue("Sheet1", "A1")
// after: correct the formula first
f.SetCellFormula("Sheet1", "A1", "=ABS(A2+1)")
cellVal, err := f.CalcCellValue("Sheet1", "A1") // now returns a number
Defensive patterns

Strategy: validation

Validate before calling

supported := map[string]bool{"SUM": true, "IF": true, "ABS": true} // fill from your excelize version's function list
func formulaUsesKnownFunctions(formula string) bool {
	for _, name := range extractFunctionNames(formula) { // regex: [A-Z0-9\.]+(?=\()
		if !supported[strings.ToUpper(name)] {
			return false
		}
	}
	return true
}

Type guard

func isFormulaError(val string) bool {
	switch val {
	case "#NAME?", "#VALUE!", "#REF!", "#DIV/0!", "#N/A":
		return true
	}
	return false
}

Try / catch

val, err := f.CalcCellValue("Sheet1", "A1")
if err != nil || val == "#NAME?" {
	// fall back to cached value or log the unsupported function
	val, _ = f.GetCellValue("Sheet1", "A1")
}

Prevention

When it happens

Trigger: Calling f.CalcCellValue(sheet, cell) where the cell formula references a function name not in the supported list (e.g. =ABS(~), =MYFUNC(1), =SUMM(A1:A2)), or a formula whose function-name token is malformed so evalInfixExpFunc cannot match it to a registered function.

Common situations: Typos in function names; formulas written for another spreadsheet engine (LibreOffice/Google Sheets functions Excelize does not implement); very old Excelize versions lacking a newer function; user-defined/localized function names; dynamic formula strings built by concatenation.

Related errors


AI-assisted analysis of qax-os/excelize@f2483381fb (2026-09-02). Data as JSON: /api/errors/50bdcd7b52ece726. Report an issue: GitHub.