You are here

protected function PHPExcel_ReferenceHelper::_adjustComments 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::_adjustComments()

* Update cell comments when inserting/deleting rows/columns * *

Parameters

PHPExcel_Worksheet $pSheet The worksheet that we're editing: * @param string $pBefore Insert/Delete before this cell address (e.g. 'A1') * @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before * @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion) * @param integer $beforeRow Number of the row we're inserting/deleting before * @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)

1 call to PHPExcel_ReferenceHelper::_adjustComments()
PHPExcel_ReferenceHelper::insertNewBefore in vendor/phpoffice/phpexcel/Classes/PHPExcel/ReferenceHelper.php
* Insert a new column or row, updating all possible related data * *

File

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

Class

PHPExcel_ReferenceHelper
PHPExcel_ReferenceHelper (Singleton)

Code

protected function _adjustComments($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) {
  $aComments = $pSheet
    ->getComments();
  $aNewComments = array();

  // the new array of all comments
  foreach ($aComments as $key => &$value) {

    // Any comments inside a deleted range will be ignored
    if (!self::cellAddressInDeleteRange($key, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols)) {

      //	Otherwise build a new array of comments indexed by the adjusted cell reference
      $newReference = $this
        ->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
      $aNewComments[$newReference] = $value;
    }
  }

  //	Replace the comments array with the new set of comments
  $pSheet
    ->setComments($aNewComments);
}