Skip to content

Cell Coordinate splitRange doesn't support space delimeter #1458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 11 commits into from
Closed
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).

- Drop support for PHP 7.1, according to https://phpspreadsheet.readthedocs.io/en/latest/#php-version-support
- Drop partial migration tool in favor of complete migration via RectorPHP [#1445](https://github.com/PHPOffice/PhpSpreadsheet/issues/1445)
- Cell Coordinate range now supports a space delimiter

## [1.12.0] - 2020-04-27

Expand Down
8 changes: 7 additions & 1 deletion src/PhpSpreadsheet/Cell/Coordinate.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,13 @@ public static function splitRange($pRange)
$pRange = self::DEFAULT_RANGE;
}

$exploded = explode(',', $pRange);
if (strpos(trim($pRange), ' ') !== false) {
$delimiter = ' ';
} else {
$delimiter = ',';
}

$exploded = explode($delimiter, $pRange);
$counter = count($exploded);
for ($i = 0; $i < $counter; ++$i) {
$exploded[$i] = explode(':', $exploded[$i]);
Expand Down
13 changes: 13 additions & 0 deletions tests/data/CellSplitRange.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,17 @@
],
'B4:E9,H2:O11',
],
[
[
[
'B4',
'E9',
],
[
'H2',
'O11',
],
],
'B4:E9 H2:O11',
],
];