/** * 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->activePane; // 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); }