{"record":{"id":"0a7b4f241dfe9505","repo":"PHPOffice/PhpSpreadsheet","slug":"num-0a7b4f","errorCode":"#NUM!","errorMessage":"#NUM!","messagePattern":"#NUM!","errorType":"exception","errorClass":"PhpOffice\\PhpSpreadsheet\\Calculation\\Exception","httpStatus":null,"severity":"error","filePath":"src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php","lineNumber":57,"sourceCode":"            }\n\n            return $retval;\n        }\n\n        self::nullFalseTrueToNumber($dateValue, $allowBool, $calendar);\n        if (!is_numeric($dateValue)) {\n            $saveReturnDateType = Functions::getReturnDateType();\n            Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);\n            if (is_string($dateValue)) {\n                $dateValue = DateValue::fromString($dateValue);\n            }\n            Functions::setReturnDateType($saveReturnDateType);\n            if (!is_numeric($dateValue)) {\n                throw new Exception(ExcelError::VALUE());\n            }\n        }\n        if ($dateValue < 0 && Functions::getCompatibilityMode() !== Functions::COMPATIBILITY_OPENOFFICE) {\n            throw new Exception(ExcelError::NAN());\n        }\n\n        try {\n            SharedDateHelper::excelToDateTimeObject((float) $dateValue, calendar: $calendar);\n        } catch (Throwable) {\n            throw new Exception(ExcelError::NAN());\n        }\n\n        return (float) $dateValue;\n    }\n\n    /**\n     * getTimeValue.\n     *\n     * @return float|string Excel date/time serial value, or string if error\n     */\n    public static function getTimeValue(string $timeValue): string|float\n    {","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/PHPOffice/PhpSpreadsheet/blob/65b080eef4d9fd11a5796135ab145883e5c3d6a6/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php#L39-L75","documentation":"Table::setName() enforces Excel's 255-character ceiling for table names using StringHelper::countCharacters(), which counts Unicode code points rather than bytes. Names longer than 255 characters cannot round-trip through Excel's defined-name and table structures, so the library rejects them up front.","triggerScenarios":"Names assembled from user text, full sentences, timestamps, or concatenated column lists exceeding 255 characters; multi-byte names pushed through a generator without any length cap.","commonSituations":"Auto-naming tables after report titles, file paths, or JSON payloads; template-based name generation without truncation.","solutions":["Truncate before setting: $table->setName(mb_substr($name, 0, 255))","Use a short generated slug ('tbl_' . $id) and keep the long text in a cell","Enforce a length cap at the input layer for anything destined to become a table name"],"exampleFix":"// before\n$table->setName($userProvidedTitle); // 300-character report title -> exception\n\n// after\n$table->setName(mb_substr($userProvidedTitle, 0, 255));","handlingStrategy":"validation","validationCode":"if (mb_strlen($name) > 255) {\n    $name = mb_substr($name, 0, 255);\n}\n$table->setName($name);","typeGuard":null,"tryCatchPattern":"try {\n    $table->setName($name);\n} catch (\\PhpOffice\\PhpSpreadsheet\\Exception $e) {\n    $table->setName(mb_substr($name, 0, 255)); // truncate and retry once\n}","preventionTips":["Cap name length where the name is generated (titles, paths, blobs)","Prefer short generated slugs for table names; keep long text in cells","Note the limit counts characters, not bytes"],"tags":["table","name-too-long","limit","validation"],"backgroundTag":"identifier-too-long","analyzedSha":"65b080eef4d9fd11a5796135ab145883e5c3d6a6","analyzedAt":"2026-08-17T05:40:41.646Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}