You are here

private function PHPExcel_ReferenceHelper::_updateSingleCellReference in Loft Data Grids 7.2

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

* Update single cell reference * *

Parameters

string $pCellReference Single cell reference: * @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 reference * @throws PHPExcel_Exception

2 calls to PHPExcel_ReferenceHelper::_updateSingleCellReference()
PHPExcel_ReferenceHelper::updateCellReference in vendor/phpoffice/phpexcel/Classes/PHPExcel/ReferenceHelper.php
* Update cell reference * *
PHPExcel_ReferenceHelper::_updateCellRange in vendor/phpoffice/phpexcel/Classes/PHPExcel/ReferenceHelper.php
* Update cell range * *

File

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

Class

PHPExcel_ReferenceHelper
PHPExcel_ReferenceHelper (Singleton)

Code

private function _updateSingleCellReference($pCellReference = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) {
  if (strpos($pCellReference, ':') === false && strpos($pCellReference, ',') === false) {

    // Get coordinates of $pBefore
    list($beforeColumn, $beforeRow) = PHPExcel_Cell::coordinateFromString($pBefore);

    // Get coordinates of $pCellReference
    list($newColumn, $newRow) = PHPExcel_Cell::coordinateFromString($pCellReference);

    // Verify which parts should be updated
    $updateColumn = $newColumn[0] != '$' && $beforeColumn[0] != '$' && PHPExcel_Cell::columnIndexFromString($newColumn) >= PHPExcel_Cell::columnIndexFromString($beforeColumn);
    $updateRow = $newRow[0] != '$' && $beforeRow[0] != '$' && $newRow >= $beforeRow;

    // Create new column reference
    if ($updateColumn) {
      $newColumn = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($newColumn) - 1 + $pNumCols);
    }

    // Create new row reference
    if ($updateRow) {
      $newRow = $newRow + $pNumRows;
    }

    // Return new reference
    return $newColumn . $newRow;
  }
  else {
    throw new PHPExcel_Exception("Only single cell references may be passed to this method.");
  }
}