PHPOffice/PhpSpreadsheet · error · PhpOffice\PhpSpreadsheet\Exception

Range does not contain any information

Error message

Range does not contain any information

What it means

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.

Source

Thrown at src/PhpSpreadsheet/Cell/Coordinate.php:201

        }

        return self::splitRange(
            self::resolveUnionAndIntersection($range)
        );
    }

    /**
     * Build range from coordinate strings.
     *
     * @param array<array<string>> $range Array containing one or more arrays containing one or two coordinate strings
     *
     * @return string String representation of $pRange
     */
    public static function buildRange(array $range): string
    {
        // Verify range
        if (empty($range)) {
            throw new Exception('Range does not contain any information');
        }

        // Build range
        $counter = count($range);
        for ($i = 0; $i < $counter; ++$i) {
            if (!is_array($range[$i])) {
                throw new Exception('Each array entry must be an array');
            }
            $range[$i] = implode(':', $range[$i]);
        }

        /** @var array<string> $range */
        return implode(',', $range);
    }

    /**
     * Calculate range boundaries.
     *

View on GitHub (pinned to 65b080eef4)

Solutions

  1. Guard for emptiness before calling: if ($coords === []) { skip or default to 'A1' }
  2. Default empty selections to a known single cell when the downstream API requires a non-empty range
  3. Log when a selection comes out empty - it usually indicates an upstream filtering bug

Example fix

// before
$range = Coordinate::buildRange($selectedCells); // throws when $selectedCells is []

// after
$range = $selectedCells === []
    ? 'A1'
    : Coordinate::buildRange($selectedCells);
Defensive patterns

Strategy: validation

Validate before calling

if ($coords === []) {
    // nothing selected: skip or default to a known anchor cell
    $range = 'A1';
} else {
    $range = Coordinate::buildRange($coords);
}

Type guard

null

Try / catch

null

Prevention

When it happens

Trigger: 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.

Common situations: Dynamic range builders for styles/defined names fed by search results; data-driven exports where an optional section has no rows this run.

Related errors


AI-assisted analysis of PHPOffice/PhpSpreadsheet@65b080eef4 (2026-08-17). Data as JSON: /api/errors/0695eec11e8f25cd. Report an issue: GitHub.