{"record":{"id":"680fba406ea04ef7","repo":"PHPOffice/PhpSpreadsheet","slug":"unrecognized-function-in-formula","errorCode":null,"errorMessage":"Unrecognized function in formula","messagePattern":"Unrecognized function in formula","errorType":"exception","errorClass":"PhpOffice\\PhpSpreadsheet\\Reader\\Exception","httpStatus":null,"severity":"error","filePath":"src/PhpSpreadsheet/Reader/Xls.php","lineNumber":4624,"sourceCode":"                break;\n            case 0x20:    //    array constant\n            case 0x40:\n            case 0x60:\n                // offset: 1; size: 7; not used\n                $name = 'tArray';\n                $size = 8;\n                $data = null;\n\n                break;\n            case 0x21:    //    function with fixed number of arguments\n            case 0x41:\n            case 0x61:\n                $name = 'tFunc';\n                $size = 3;\n                // offset: 1; size: 2; index to built-in sheet function\n                $mapping = Xls\\Mappings::TFUNC_MAPPINGS[self::getUInt2d($formulaData, 1)] ?? null;\n                if ($mapping === null) {\n                    throw new Exception('Unrecognized function in formula');\n                }\n                $data = ['function' => $mapping[0], 'args' => $mapping[1]];\n\n                break;\n            case 0x22:    //    function with variable number of arguments\n            case 0x42:\n            case 0x62:\n                $name = 'tFuncV';\n                $size = 4;\n                // offset: 1; size: 1; number of arguments\n                $args = ord($formulaData[1]);\n                // offset: 2: size: 2; index to built-in sheet function\n                $index = self::getUInt2d($formulaData, 2);\n                $function = Xls\\Mappings::TFUNCV_MAPPINGS[$index] ?? null;\n                if ($function === null) {\n                    throw new Exception('Unrecognized function in formula');\n                }\n                $data = ['function' => $function, 'args' => $args];","sourceCodeStart":4606,"sourceCodeEnd":4642,"githubUrl":"https://github.com/PHPOffice/PhpSpreadsheet/blob/65b080eef4d9fd11a5796135ab145883e5c3d6a6/src/PhpSpreadsheet/Reader/Xls.php#L4606-L4642","documentation":"A tFunc token references a built-in sheet function by 2-byte index, and that index has no entry in the reader's TFUNC_MAPPINGS table. The file uses a function slot PhpSpreadsheet's mapping table does not know, so it cannot render the formula.","triggerScenarios":"Loading an .xls saved by a newer Excel that occupied previously-reserved function indexes, or a writer that emitted a wrong index; corrupt bytes in the token produce the same effect.","commonSituations":"Workbooks authored in a later Office version than the library's mapping table covers; spreadsheets generated by third-party toolkits with hand-rolled BIFF output.","solutions":["Upgrade PhpSpreadsheet — function maps gain entries over releases","Open the file in Excel, replace the newer function with a classic equivalent (e.g. replace XLOOKUP with INDEX/MATCH), and re-save","Re-save as .xlsx and use the Xlsx reader, whose function handling is broader","If unreachable, strip the formulas (paste-values) before import"],"exampleFix":"// before\n$spreadsheet = IOFactory::load('newfuncs.xls'); // Unrecognized function in formula\n\n// after: convert to xlsx, whose reader handles newer functions\nshell_exec('soffice --headless --convert-to xlsx --outdir /tmp newfuncs.xls');\n$spreadsheet = IOFactory::load('/tmp/newfuncs.xlsx');","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    $spreadsheet = IOFactory::load($path);\n} catch (\\PhpOffice\\PhpSpreadsheet\\Reader\\Exception $e) {\n    if (str_contains($e->getMessage(), 'Unrecognized function')) {\n        $reader = new \\PhpOffice\\PhpSpreadsheet\\Reader\\Xls();\n        $reader->setReadDataOnly(true);\n        $spreadsheet = $reader->load($path); // values-only fallback\n    }\n}","preventionTips":["Pin a recent PhpSpreadsheet version so function maps cover current Excel","Discourage newly-released worksheet functions in files destined for import","Prefer .xlsx over .xls for machine-to-machine exchange"],"tags":["xls","formula","function-mapping","biff","phpspreadsheet"],"backgroundTag":"unknown-formula-function","analyzedSha":"65b080eef4d9fd11a5796135ab145883e5c3d6a6","analyzedAt":"2026-08-17T05:40:41.646Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}