{"record":{"id":"50bdcd7b52ece726","repo":"qax-os/excelize","slug":"name","errorCode":"#NAME?","errorMessage":"#NAME?","messagePattern":"#NAME\\?","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"calc.go","lineNumber":1146,"sourceCode":"\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif inArrayRow && isOperand(token) {\n\t\t\t\tformulaArrayRow = append(formulaArrayRow, opfdStack.Pop().(formulaArg))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif inArrayRow && isFunctionStopToken(token) {\n\t\t\t\tformulaArray = append(formulaArray, formulaArrayRow)\n\t\t\t\tinArrayRow = false\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif inArray && isFunctionStopToken(token) {\n\t\t\t\targsStack.Peek().(*list.List).PushBack(newMatrixFormulaArg(formulaArray))\n\t\t\t\tinArray = false\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif errArg := f.evalInfixExpFunc(ctx, sheet, cell, token, nextToken, opfStack, opdStack, opftStack, opfdStack, argsStack); errArg.Type == ArgError {\n\t\t\t\treturn errArg, errors.New(errArg.Error)\n\t\t\t}\n\t\t}\n\t}\n\tfor optStack.Len() != 0 {\n\t\ttopOpt := optStack.Peek().(efp.Token)\n\t\tif err = calculate(opdStack, topOpt); err != nil {\n\t\t\treturn newErrorFormulaArg(err.Error(), err.Error()), err\n\t\t}\n\t\toptStack.Pop()\n\t}\n\tif opdStack.Len() == 0 {\n\t\treturn newEmptyFormulaArg(), ErrInvalidFormula\n\t}\n\tif result := opdStack.Peek().(formulaArg); result.Type == ArgError {\n\t\treturn result, errors.New(result.Error)\n\t}\n\treturn opdStack.Peek().(formulaArg), err\n}","sourceCodeStart":1128,"sourceCodeEnd":1164,"githubUrl":"https://github.com/qax-os/excelize/blob/f2483381fbfbe432a6baa98d48a1c277183f3285/calc.go#L1128-L1164","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the formula text in the cell and fix the function name spelling against the list of functions supported by your Excelize version.","Upgrade github.com/xuri/excelize to the latest version, as new formula functions are added regularly.","Replace unsupported/custom functions with an equivalent supported function, or compute the value in Go and write the result instead of a formula.","Check the error string returned alongside #NAME? (e.g. 'invalid reference') for the specific sub-cause."],"exampleFix":"// before: cell contains \"=ABS(~+1)\" -> CalcCellValue returns \"#NAME?\"\ncellVal, err := f.CalcCellValue(\"Sheet1\", \"A1\")\n// after: correct the formula first\nf.SetCellFormula(\"Sheet1\", \"A1\", \"=ABS(A2+1)\")\ncellVal, err := f.CalcCellValue(\"Sheet1\", \"A1\") // now returns a number","handlingStrategy":"validation","validationCode":"supported := map[string]bool{\"SUM\": true, \"IF\": true, \"ABS\": true} // fill from your excelize version's function list\nfunc formulaUsesKnownFunctions(formula string) bool {\n\tfor _, name := range extractFunctionNames(formula) { // regex: [A-Z0-9\\.]+(?=\\()\n\t\tif !supported[strings.ToUpper(name)] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}","typeGuard":"func isFormulaError(val string) bool {\n\tswitch val {\n\tcase \"#NAME?\", \"#VALUE!\", \"#REF!\", \"#DIV/0!\", \"#N/A\":\n\t\treturn true\n\t}\n\treturn false\n}","tryCatchPattern":"val, err := f.CalcCellValue(\"Sheet1\", \"A1\")\nif err != nil || val == \"#NAME?\" {\n\t// fall back to cached value or log the unsupported function\n\tval, _ = f.GetCellValue(\"Sheet1\", \"A1\")\n}","preventionTips":["Verify every function name in generated formulas against the excelize function support list for your pinned version.","Avoid building formulas by string concatenation from unvalidated input.","Pin and regularly upgrade excelize to pick up newly supported functions.","Write tests that call CalcCellValue on every formula template you ship."],"tags":["formula","excel","spreadsheet","go"],"backgroundTag":"formula-name-error","analyzedSha":"f2483381fbfbe432a6baa98d48a1c277183f3285","analyzedAt":"2026-09-02T01:26:19.299Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}