{"record":{"id":"cdad917c677a39d7","repo":"PHPOffice/PhpSpreadsheet","slug":"unrecognized-attribute-flag-in-tattr-token","errorCode":null,"errorMessage":"Unrecognized attribute flag in tAttr token","messagePattern":"Unrecognized attribute flag in tAttr token","errorType":"exception","errorClass":"PhpOffice\\PhpSpreadsheet\\Reader\\Exception","httpStatus":null,"severity":"error","filePath":"src/PhpSpreadsheet/Reader/Xls.php","lineNumber":4574,"sourceCode":"                        $size = 4;\n                        // offset: 2; size: 2; space type and position\n                        $spacetype = match (ord($formulaData[2])) {\n                            0x00 => 'type0',\n                            0x01 => 'type1',\n                            0x02 => 'type2',\n                            0x03 => 'type3',\n                            0x04 => 'type4',\n                            0x05 => 'type5',\n                            default => throw new Exception('Unrecognized space type in tAttrSpace token'),\n                        };\n                        // offset: 3; size: 1; number of inserted spaces/carriage returns\n                        $spacecount = ord($formulaData[3]);\n\n                        $data = ['spacetype' => $spacetype, 'spacecount' => $spacecount];\n\n                        break;\n                    default:\n                        throw new Exception('Unrecognized attribute flag in tAttr token');\n                }\n\n                break;\n            case 0x1C:    //    error code\n                // offset: 1; size: 1; error code\n                $name = 'tErr';\n                $size = 2;\n                $data = Xls\\ErrorCode::lookup(ord($formulaData[1]));\n\n                break;\n            case 0x1D:    //    boolean\n                // offset: 1; size: 1; 0 = false, 1 = true;\n                $name = 'tBool';\n                $size = 2;\n                $data = ord($formulaData[1]) ? 'TRUE' : 'FALSE';\n\n                break;\n            case 0x1E:    //    integer","sourceCodeStart":4556,"sourceCodeEnd":4592,"githubUrl":"https://github.com/PHPOffice/PhpSpreadsheet/blob/65b080eef4d9fd11a5796135ab145883e5c3d6a6/src/PhpSpreadsheet/Reader/Xls.php#L4556-L4592","documentation":"Inside a tAttr formula token, only specific attribute flags are recognized (volatile, if/else, for, skip, and 0x40/0x41 space variants). The token's flag byte had some other bit pattern set, so the reader refuses to guess the token size and aborts.","triggerScenarios":"A FORMULA record written with a non-standard grbit in the tAttr token by a third-party BIFF writer, or bit-flipped/corrupted file bytes that turn a valid flag into an unknown one.","commonSituations":"Workbooks produced by legacy export libraries or converters; files that survived partial disk failure; results of naive byte-level preprocessing (e.g. encoding conversion applied to a binary file).","solutions":["Open and re-save the workbook in Excel (or 'Open and Repair') so the formula records are rewritten canonically","Re-export the file from its source system with a current exporter","Confirm the file was not mangled in transit (re-download/re-transfer in binary mode)","Upgrade PhpSpreadsheet in case newly-flagged attributes are supported"],"exampleFix":null,"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(), 'tAttr')) {\n        // formula record is nonstandard: request a canonically re-saved file\n    }\n}","preventionTips":["Validate producer output against real Excel files periodically","Transfer workbooks in binary mode only (no encoding conversions)","Isolate single-sheet loads with setLoadSheetsOnly() to locate the bad formula quickly"],"tags":["xls","formula","biff","token-parser","phpspreadsheet"],"backgroundTag":"malformed-formula-token","analyzedSha":"65b080eef4d9fd11a5796135ab145883e5c3d6a6","analyzedAt":"2026-08-17T05:40:41.646Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}