You are here

private function PHPExcel_ReferenceHelper::_updateCellRange in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/ReferenceHelper.php \PHPExcel_ReferenceHelper::_updateCellRange()

* Update cell range * *

Parameters

string $pCellRange Cell range (e.g. 'B2:D4', 'B:C' or '2:3'): * @param int $pBefore Insert before this one * @param int $pNumCols Number of columns to increment * @param int $pNumRows Number of rows to increment * @return string Updated cell range * @throws PHPExcel_Exception

1 call to PHPExcel_ReferenceHelper::_updateCellRange()
PHPExcel_ReferenceHelper::updateCellReference in vendor/phpoffice/phpexcel/Classes/PHPExcel/ReferenceHelper.php
* Update cell reference * *

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/ReferenceHelper.php, line 846

Class

PHPExcel_ReferenceHelper
PHPExcel_ReferenceHelper (Singleton)

Code

private function _updateCellRange($pCellRange = 'A1:A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) {
  if (strpos($pCellRange, ':') !== false || strpos($pCellRange, ',') !== false) {

    // Update range
    $range = PHPExcel_Cell::splitRange($pCellRange);
    $ic = count($range);
    for ($i = 0; $i < $ic; ++$i) {
      $jc = count($range[$i]);
      for ($j = 0; $j < $jc; ++$j) {
        if (ctype_alpha($range[$i][$j])) {
          $r = PHPExcel_Cell::coordinateFromString($this
            ->_updateSingleCellReference($range[$i][$j] . '1', $pBefore, $pNumCols, $pNumRows));
          $range[$i][$j] = $r[0];
        }
        elseif (ctype_digit($range[$i][$j])) {
          $r = PHPExcel_Cell::coordinateFromString($this
            ->_updateSingleCellReference('A' . $range[$i][$j], $pBefore, $pNumCols, $pNumRows));
          $range[$i][$j] = $r[1];
        }
        else {
          $range[$i][$j] = $this
            ->_updateSingleCellReference($range[$i][$j], $pBefore, $pNumCols, $pNumRows);
        }
      }
    }

    // Recreate range string
    return PHPExcel_Cell::buildRange($range);
  }
  else {
    throw new PHPExcel_Exception("Only cell ranges may be passed to this method.");
  }
}