You are here

private function PHPExcel_Writer_Excel5_Worksheet::_writeSelection in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5/Worksheet.php \PHPExcel_Writer_Excel5_Worksheet::_writeSelection()

* Write BIFF record SELECTION.

1 call to PHPExcel_Writer_Excel5_Worksheet::_writeSelection()
PHPExcel_Writer_Excel5_Worksheet::close in vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5/Worksheet.php
* Add data to the beginning of the workbook (note the reverse order) * and to the end of the workbook. * * @access public *

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5/Worksheet.php, line 1439

Class

PHPExcel_Writer_Excel5_Worksheet
PHPExcel_Writer_Excel5_Worksheet

Code

private function _writeSelection() {

  // look up the selected cell range
  $selectedCells = $this->_phpSheet
    ->getSelectedCells();
  $selectedCells = PHPExcel_Cell::splitRange($this->_phpSheet
    ->getSelectedCells());
  $selectedCells = $selectedCells[0];
  if (count($selectedCells) == 2) {
    list($first, $last) = $selectedCells;
  }
  else {
    $first = $selectedCells[0];
    $last = $selectedCells[0];
  }
  list($colFirst, $rwFirst) = PHPExcel_Cell::coordinateFromString($first);
  $colFirst = PHPExcel_Cell::columnIndexFromString($colFirst) - 1;

  // base 0 column index
  --$rwFirst;

  // base 0 row index
  list($colLast, $rwLast) = PHPExcel_Cell::coordinateFromString($last);
  $colLast = PHPExcel_Cell::columnIndexFromString($colLast) - 1;

  // base 0 column index
  --$rwLast;

  // base 0 row index
  // make sure we are not out of bounds
  $colFirst = min($colFirst, 255);
  $colLast = min($colLast, 255);
  $rwFirst = min($rwFirst, 65535);
  $rwLast = min($rwLast, 65535);
  $record = 0x1d;

  // Record identifier
  $length = 0xf;

  // Number of bytes to follow
  $pnn = $this->_active_pane;

  // Pane position
  $rwAct = $rwFirst;

  // Active row
  $colAct = $colFirst;

  // Active column
  $irefAct = 0;

  // Active cell ref
  $cref = 1;

  // Number of refs
  if (!isset($rwLast)) {
    $rwLast = $rwFirst;

    // Last  row in reference
  }
  if (!isset($colLast)) {
    $colLast = $colFirst;

    // Last  col in reference
  }

  // Swap last row/col for first row/col as necessary
  if ($rwFirst > $rwLast) {
    list($rwFirst, $rwLast) = array(
      $rwLast,
      $rwFirst,
    );
  }
  if ($colFirst > $colLast) {
    list($colFirst, $colLast) = array(
      $colLast,
      $colFirst,
    );
  }
  $header = pack("vv", $record, $length);
  $data = pack("CvvvvvvCC", $pnn, $rwAct, $colAct, $irefAct, $cref, $rwFirst, $rwLast, $colFirst, $colLast);
  $this
    ->_append($header . $data);
}