Example #1
0
 /**
  * Write BIFF record SELECTION.
  */
 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);
 }