{"record":{"id":"27ae1b6448845327","repo":"PHPOffice/PhpSpreadsheet","slug":"unable-to-read-data-from-pfilename","errorCode":null,"errorMessage":"Unable to read data from {$pFilename}","messagePattern":"Unable to read data from (.+?)","errorType":"exception","errorClass":"PhpOffice\\PhpSpreadsheet\\Reader\\Exception","httpStatus":null,"severity":"error","filePath":"src/PhpSpreadsheet/Reader/Ods.php","lineNumber":325,"sourceCode":"\n    /**\n     * Loads PhpSpreadsheet from file into PhpSpreadsheet instance.\n     */\n    public function loadIntoExisting(string $filename, Spreadsheet $spreadsheet): Spreadsheet\n    {\n        File::assertFile($filename, self::INITIAL_FILE);\n\n        $zip = new ZipArchive();\n        $zip->open($filename);\n\n        // Meta\n\n        $xml = @simplexml_load_string(\n            $this->getSecurityScannerOrThrow()\n                ->scan($zip->getFromName('meta.xml'))\n        );\n        if ($xml === false) {\n            throw new Exception('Unable to read data from {$pFilename}');\n        }\n\n        /** @var array{meta?: string, office?: string, dc?: string} */\n        $namespacesMeta = $xml->getNamespaces(true);\n\n        (new DocumentProperties($spreadsheet))->load($xml, $namespacesMeta);\n\n        // Styles\n\n        $this->allStyles = $this->numberFormats = [];\n        $dom = new DOMDocument('1.01', 'UTF-8');\n        $dom->loadXML(\n            $this->getSecurityScannerOrThrow()\n                ->scan($zip->getFromName('styles.xml'))\n        );\n        $officeNs = (string) $dom->lookupNamespaceUri('office');\n        $styleNs = (string) $dom->lookupNamespaceUri('style');\n        $fontNs = (string) $dom->lookupNamespaceUri('fo');","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/PHPOffice/PhpSpreadsheet/blob/65b080eef4d9fd11a5796135ab145883e5c3d6a6/src/PhpSpreadsheet/Reader/Ods.php#L307-L343","documentation":"The Ods reader opens the file as a ZipArchive and parses its meta.xml entry with simplexml. When that entry is missing, empty, or unparseable, it throws 'Unable to read data from {$pFilename}'. Upstream bug worth knowing: the message is single-quoted, so it literally prints {$pFilename} and never shows the actual filename (the code variable is even named $filename).","triggerScenarios":"An .ods whose zip lacks meta.xml (some third-party generators omit it); a corrupt or truncated archive; a non-ODS zip merely renamed .ods; interrupted downloads.","commonSituations":"Files produced by lightweight Java/Python ODS writers that skip meta.xml; uploads corrupted in transit; archives rebuilt by tools that dropped entries.","solutions":["Re-save the file in LibreOffice or Excel so a complete, valid ODS (including meta.xml) is regenerated","Verify the archive contents (unzip -l file.ods should list meta.xml); if absent, rebuild the zip with a minimal meta.xml or re-export","Use IOFactory::identify() to confirm the file really is an ODS before blaming the reader"],"exampleFix":"# before (shell): file is an ODS lacking meta.xml\n$spreadsheet = (new Ods())->load('report.ods'); // throws literal 'Unable to read data from {$pFilename}'\n\n# after: regenerate a complete archive first\nsoffice --headless --convert-to ods --outdir fixed report.ods\n$spreadsheet = (new Ods())->load('fixed/report.ods');","handlingStrategy":"validation","validationCode":"$zip = new ZipArchive();\nif ($zip->open($filename) !== true || $zip->locateName('meta.xml') === false) {\n    throw new RuntimeException('ODS archive missing or lacks meta.xml: ' . $filename);\n}\n$zip->close();\n$spreadsheet = (new Ods())->load($filename);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pre-flight unknown ODS files with a ZipArchive meta.xml check","Re-save odd exports through LibreOffice to normalize archive structure","Remember the exception text literally says {$pFilename} — the filename is absent, so log your own path context"],"tags":["ods","zip","opendocument","corrupt-file","upstream-bug"],"backgroundTag":"archive-entry-missing","analyzedSha":"65b080eef4d9fd11a5796135ab145883e5c3d6a6","analyzedAt":"2026-08-17T05:40:41.646Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}