You are here

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

* Update row dimensions 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::_adjustRowDimensions()
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 350

Class

PHPExcel_ReferenceHelper
PHPExcel_ReferenceHelper (Singleton)

Code

protected function _adjustRowDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows) {
  $aRowDimensions = array_reverse($pSheet
    ->getRowDimensions(), true);
  if (!empty($aRowDimensions)) {
    foreach ($aRowDimensions as $objRowDimension) {
      $newReference = $this
        ->updateCellReference('A' . $objRowDimension
        ->getRowIndex(), $pBefore, $pNumCols, $pNumRows);
      list(, $newReference) = PHPExcel_Cell::coordinateFromString($newReference);
      if ($objRowDimension
        ->getRowIndex() != $newReference) {
        $objRowDimension
          ->setRowIndex($newReference);
      }
    }
    $pSheet
      ->refreshRowDimensions();
    $copyDimension = $pSheet
      ->getRowDimension($beforeRow - 1);
    for ($i = $beforeRow; $i <= $beforeRow - 1 + $pNumRows; ++$i) {
      $newDimension = $pSheet
        ->getRowDimension($i);
      $newDimension
        ->setRowHeight($copyDimension
        ->getRowHeight());
      $newDimension
        ->setVisible($copyDimension
        ->getVisible());
      $newDimension
        ->setOutlineLevel($copyDimension
        ->getOutlineLevel());
      $newDimension
        ->setCollapsed($copyDimension
        ->getCollapsed());
    }
  }
}