You are here

private function PHPExcel_Reader_Excel5::_readSelection in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel5.php \PHPExcel_Reader_Excel5::_readSelection()

* Read SELECTION record. There is one such record for each pane in the sheet.

1 call to PHPExcel_Reader_Excel5::_readSelection()
PHPExcel_Reader_Excel5::load in vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel5.php
* Loads PHPExcel from file * *

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel5.php, line 4385

Class

PHPExcel_Reader_Excel5
PHPExcel_Reader_Excel5

Code

private function _readSelection() {
  $length = self::_GetInt2d($this->_data, $this->_pos + 2);
  $recordData = $this
    ->_readRecordData($this->_data, $this->_pos + 4, $length);

  // move stream pointer to next record
  $this->_pos += 4 + $length;
  if (!$this->_readDataOnly) {

    // offset: 0; size: 1; pane identifier
    $paneId = ord($recordData[0]);

    // offset: 1; size: 2; index to row of the active cell
    $r = self::_GetInt2d($recordData, 1);

    // offset: 3; size: 2; index to column of the active cell
    $c = self::_GetInt2d($recordData, 3);

    // offset: 5; size: 2; index into the following cell range list to the
    //  entry that contains the active cell
    $index = self::_GetInt2d($recordData, 5);

    // offset: 7; size: var; cell range address list containing all selected cell ranges
    $data = substr($recordData, 7);
    $cellRangeAddressList = $this
      ->_readBIFF5CellRangeAddressList($data);

    // note: also BIFF8 uses BIFF5 syntax
    $selectedCells = $cellRangeAddressList['cellRangeAddresses'][0];

    // first row '1' + last row '16384' indicates that full column is selected (apparently also in BIFF8!)
    if (preg_match('/^([A-Z]+1\\:[A-Z]+)16384$/', $selectedCells)) {
      $selectedCells = preg_replace('/^([A-Z]+1\\:[A-Z]+)16384$/', '${1}1048576', $selectedCells);
    }

    // first row '1' + last row '65536' indicates that full column is selected
    if (preg_match('/^([A-Z]+1\\:[A-Z]+)65536$/', $selectedCells)) {
      $selectedCells = preg_replace('/^([A-Z]+1\\:[A-Z]+)65536$/', '${1}1048576', $selectedCells);
    }

    // first column 'A' + last column 'IV' indicates that full row is selected
    if (preg_match('/^(A[0-9]+\\:)IV([0-9]+)$/', $selectedCells)) {
      $selectedCells = preg_replace('/^(A[0-9]+\\:)IV([0-9]+)$/', '${1}XFD${2}', $selectedCells);
    }
    $this->_phpSheet
      ->setSelectedCells($selectedCells);
  }
}