{"record":{"id":"0695eec11e8f25cd","repo":"PHPOffice/PhpSpreadsheet","slug":"range-does-not-contain-any-information","errorCode":null,"errorMessage":"Range does not contain any information","messagePattern":"Range does not contain any information","errorType":"exception","errorClass":"PhpOffice\\PhpSpreadsheet\\Exception","httpStatus":null,"severity":"error","filePath":"src/PhpSpreadsheet/Cell/Coordinate.php","lineNumber":201,"sourceCode":"        }\n\n        return self::splitRange(\n            self::resolveUnionAndIntersection($range)\n        );\n    }\n\n    /**\n     * Build range from coordinate strings.\n     *\n     * @param array<array<string>> $range Array containing one or more arrays containing one or two coordinate strings\n     *\n     * @return string String representation of $pRange\n     */\n    public static function buildRange(array $range): string\n    {\n        // Verify range\n        if (empty($range)) {\n            throw new Exception('Range does not contain any information');\n        }\n\n        // Build range\n        $counter = count($range);\n        for ($i = 0; $i < $counter; ++$i) {\n            if (!is_array($range[$i])) {\n                throw new Exception('Each array entry must be an array');\n            }\n            $range[$i] = implode(':', $range[$i]);\n        }\n\n        /** @var array<string> $range */\n        return implode(',', $range);\n    }\n\n    /**\n     * Calculate range boundaries.\n     *","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/PHPOffice/PhpSpreadsheet/blob/65b080eef4d9fd11a5796135ab145883e5c3d6a6/src/PhpSpreadsheet/Cell/Coordinate.php#L183-L219","documentation":"Coordinate::buildRange() turns a structured array of coordinate strings into a range string; its first validation rejects an empty array with 'Range does not contain any information'. An empty input means no cells were selected, so there is nothing to build - the library surfaces the caller's empty state instead of returning an empty string.","triggerScenarios":"buildRange([]) after a filter/match step yielded no coordinates; buildRange($coords) where $coords was conditionally populated and ended up empty; callers passing a computed selection without checking it.","commonSituations":"Dynamic range builders for styles/defined names fed by search results; data-driven exports where an optional section has no rows this run.","solutions":["Guard for emptiness before calling: if ($coords === []) { skip or default to 'A1' }","Default empty selections to a known single cell when the downstream API requires a non-empty range","Log when a selection comes out empty - it usually indicates an upstream filtering bug"],"exampleFix":"// before\n$range = Coordinate::buildRange($selectedCells); // throws when $selectedCells is []\n\n// after\n$range = $selectedCells === []\n    ? 'A1'\n    : Coordinate::buildRange($selectedCells);","handlingStrategy":"validation","validationCode":"if ($coords === []) {\n    // nothing selected: skip or default to a known anchor cell\n    $range = 'A1';\n} else {\n    $range = Coordinate::buildRange($coords);\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Count the selection before building ranges; empty usually signals an upstream filter bug","Default dynamic selections to a known single cell when downstream code requires a range","Add an early assertion/log when a computed selection comes out empty"],"tags":["phpspreadsheet","coordinate","range","argument-validation","empty-input"],"backgroundTag":"malformed-range-input","analyzedSha":"65b080eef4d9fd11a5796135ab145883e5c3d6a6","analyzedAt":"2026-08-17T05:40:41.646Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}