示例#1
0
 /**
  * Writes the Excel BIFF PANE record.
  * The panes can either be frozen or thawed (unfrozen).
  * Frozen panes are specified in terms of an integer number of rows and columns.
  * Thawed panes are specified in terms of Excel's units for rows and columns.
  */
 private function writePanes()
 {
     $panes = array();
     if ($freezePane = $this->phpSheet->getFreezePane()) {
         list($column, $row) = \PHPExcel\Cell::coordinateFromString($freezePane);
         $panes[0] = $row - 1;
         $panes[1] = \PHPExcel\Cell::columnIndexFromString($column) - 1;
     } else {
         // thaw panes
         return;
     }
     $y = isset($panes[0]) ? $panes[0] : null;
     $x = isset($panes[1]) ? $panes[1] : null;
     $rwTop = isset($panes[2]) ? $panes[2] : null;
     $colLeft = isset($panes[3]) ? $panes[3] : null;
     if (count($panes) > 4) {
         // if Active pane was received
         $pnnAct = $panes[4];
     } else {
         $pnnAct = null;
     }
     $record = 0x41;
     // Record identifier
     $length = 0xa;
     // Number of bytes to follow
     // Code specific to frozen or thawed panes.
     if ($this->phpSheet->getFreezePane()) {
         // Set default values for $rwTop and $colLeft
         if (!isset($rwTop)) {
             $rwTop = $y;
         }
         if (!isset($colLeft)) {
             $colLeft = $x;
         }
     } else {
         // Set default values for $rwTop and $colLeft
         if (!isset($rwTop)) {
             $rwTop = 0;
         }
         if (!isset($colLeft)) {
             $colLeft = 0;
         }
         // Convert Excel's row and column units to the internal units.
         // The default row height is 12.75
         // The default column width is 8.43
         // The following slope and intersection values were interpolated.
         //
         $y = 20 * $y + 255;
         $x = 113.879 * $x + 390;
     }
     // Determine which pane should be active. There is also the undocumented
     // option to override this should it be necessary: may be removed later.
     //
     if (!isset($pnnAct)) {
         if ($x != 0 && $y != 0) {
             $pnnAct = 0;
             // Bottom right
         }
         if ($x != 0 && $y == 0) {
             $pnnAct = 1;
             // Top right
         }
         if ($x == 0 && $y != 0) {
             $pnnAct = 2;
             // Bottom left
         }
         if ($x == 0 && $y == 0) {
             $pnnAct = 3;
             // Top left
         }
     }
     $this->activePane = $pnnAct;
     // Used in writeSelection
     $header = pack("vv", $record, $length);
     $data = pack("vvvvv", $x, $y, $rwTop, $colLeft, $pnnAct);
     $this->append($header . $data);
 }