Eliminate some code duplication

This commit is contained in:
Mark Baker 2013-10-13 17:09:09 +01:00
parent b6e09de195
commit 9d22445673

View File

@ -1485,26 +1485,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$xfIndex = $pCellStyle->getIndex(); $xfIndex = $pCellStyle->getIndex();
} }
// Uppercase coordinate
$pRange = strtoupper($pRange);
// Is it a cell range or a single cell?
$rangeA = '';
$rangeB = '';
if (strpos($pRange, ':') === false) {
$rangeA = $pRange;
$rangeB = $pRange;
} else {
list($rangeA, $rangeB) = explode(':', $pRange);
}
// Calculate range outer borders // Calculate range outer borders
$rangeStart = PHPExcel_Cell::coordinateFromString($rangeA); list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($pRange . ':' . $pRange);
$rangeEnd = PHPExcel_Cell::coordinateFromString($rangeB);
// Translate column into index
$rangeStart[0] = PHPExcel_Cell::columnIndexFromString($rangeStart[0]) - 1;
$rangeEnd[0] = PHPExcel_Cell::columnIndexFromString($rangeEnd[0]) - 1;
// Make sure we can loop upwards on rows and columns // Make sure we can loop upwards on rows and columns
if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) { if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) {
@ -1541,26 +1523,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
} }
} }
// Uppercase coordinate
$pRange = strtoupper($pRange);
// Is it a cell range or a single cell?
$rangeA = '';
$rangeB = '';
if (strpos($pRange, ':') === false) {
$rangeA = $pRange;
$rangeB = $pRange;
} else {
list($rangeA, $rangeB) = explode(':', $pRange);
}
// Calculate range outer borders // Calculate range outer borders
$rangeStart = PHPExcel_Cell::coordinateFromString($rangeA); list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($pRange . ':' . $pRange);
$rangeEnd = PHPExcel_Cell::coordinateFromString($rangeB);
// Translate column into index
$rangeStart[0] = PHPExcel_Cell::columnIndexFromString($rangeStart[0]) - 1;
$rangeEnd[0] = PHPExcel_Cell::columnIndexFromString($rangeEnd[0]) - 1;
// Make sure we can loop upwards on rows and columns // Make sure we can loop upwards on rows and columns
if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) { if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) {