You are here

private function PHPExcel_Reader_Excel5::_readXfExt in Loft Data Grids 6.2

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

*

1 call to PHPExcel_Reader_Excel5::_readXfExt()
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 2294

Class

PHPExcel_Reader_Excel5
PHPExcel_Reader_Excel5

Code

private function _readXfExt() {
  $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: 2; 0x087D = repeated header
    // offset: 2; size: 2
    // offset: 4; size: 8; not used
    // offset: 12; size: 2; record version
    // offset: 14; size: 2; index to XF record which this record modifies
    $ixfe = self::_GetInt2d($recordData, 14);

    // offset: 16; size: 2; not used
    // offset: 18; size: 2; number of extension properties that follow
    $cexts = self::_GetInt2d($recordData, 18);

    // start reading the actual extension data
    $offset = 20;
    while ($offset < $length) {

      // extension type
      $extType = self::_GetInt2d($recordData, $offset);

      // extension length
      $cb = self::_GetInt2d($recordData, $offset + 2);

      // extension data
      $extData = substr($recordData, $offset + 4, $cb);
      switch ($extType) {
        case 4:

          // fill start color
          $xclfType = self::_GetInt2d($extData, 0);

          // color type
          $xclrValue = substr($extData, 4, 4);

          // color value (value based on color type)
          if ($xclfType == 2) {
            $rgb = sprintf('%02X%02X%02X', ord($xclrValue[0]), ord($xclrValue[1]), ord($xclrValue[2]));

            // modify the relevant style property
            if (isset($this->_mapCellXfIndex[$ixfe])) {
              $fill = $this->_phpExcel
                ->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])
                ->getFill();
              $fill
                ->getStartColor()
                ->setRGB($rgb);
              unset($fill->startcolorIndex);

              // normal color index does not apply, discard
            }
          }
          break;
        case 5:

          // fill end color
          $xclfType = self::_GetInt2d($extData, 0);

          // color type
          $xclrValue = substr($extData, 4, 4);

          // color value (value based on color type)
          if ($xclfType == 2) {
            $rgb = sprintf('%02X%02X%02X', ord($xclrValue[0]), ord($xclrValue[1]), ord($xclrValue[2]));

            // modify the relevant style property
            if (isset($this->_mapCellXfIndex[$ixfe])) {
              $fill = $this->_phpExcel
                ->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])
                ->getFill();
              $fill
                ->getEndColor()
                ->setRGB($rgb);
              unset($fill->endcolorIndex);

              // normal color index does not apply, discard
            }
          }
          break;
        case 7:

          // border color top
          $xclfType = self::_GetInt2d($extData, 0);

          // color type
          $xclrValue = substr($extData, 4, 4);

          // color value (value based on color type)
          if ($xclfType == 2) {
            $rgb = sprintf('%02X%02X%02X', ord($xclrValue[0]), ord($xclrValue[1]), ord($xclrValue[2]));

            // modify the relevant style property
            if (isset($this->_mapCellXfIndex[$ixfe])) {
              $top = $this->_phpExcel
                ->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])
                ->getBorders()
                ->getTop();
              $top
                ->getColor()
                ->setRGB($rgb);
              unset($top->colorIndex);

              // normal color index does not apply, discard
            }
          }
          break;
        case 8:

          // border color bottom
          $xclfType = self::_GetInt2d($extData, 0);

          // color type
          $xclrValue = substr($extData, 4, 4);

          // color value (value based on color type)
          if ($xclfType == 2) {
            $rgb = sprintf('%02X%02X%02X', ord($xclrValue[0]), ord($xclrValue[1]), ord($xclrValue[2]));

            // modify the relevant style property
            if (isset($this->_mapCellXfIndex[$ixfe])) {
              $bottom = $this->_phpExcel
                ->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])
                ->getBorders()
                ->getBottom();
              $bottom
                ->getColor()
                ->setRGB($rgb);
              unset($bottom->colorIndex);

              // normal color index does not apply, discard
            }
          }
          break;
        case 9:

          // border color left
          $xclfType = self::_GetInt2d($extData, 0);

          // color type
          $xclrValue = substr($extData, 4, 4);

          // color value (value based on color type)
          if ($xclfType == 2) {
            $rgb = sprintf('%02X%02X%02X', ord($xclrValue[0]), ord($xclrValue[1]), ord($xclrValue[2]));

            // modify the relevant style property
            if (isset($this->_mapCellXfIndex[$ixfe])) {
              $left = $this->_phpExcel
                ->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])
                ->getBorders()
                ->getLeft();
              $left
                ->getColor()
                ->setRGB($rgb);
              unset($left->colorIndex);

              // normal color index does not apply, discard
            }
          }
          break;
        case 10:

          // border color right
          $xclfType = self::_GetInt2d($extData, 0);

          // color type
          $xclrValue = substr($extData, 4, 4);

          // color value (value based on color type)
          if ($xclfType == 2) {
            $rgb = sprintf('%02X%02X%02X', ord($xclrValue[0]), ord($xclrValue[1]), ord($xclrValue[2]));

            // modify the relevant style property
            if (isset($this->_mapCellXfIndex[$ixfe])) {
              $right = $this->_phpExcel
                ->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])
                ->getBorders()
                ->getRight();
              $right
                ->getColor()
                ->setRGB($rgb);
              unset($right->colorIndex);

              // normal color index does not apply, discard
            }
          }
          break;
        case 11:

          // border color diagonal
          $xclfType = self::_GetInt2d($extData, 0);

          // color type
          $xclrValue = substr($extData, 4, 4);

          // color value (value based on color type)
          if ($xclfType == 2) {
            $rgb = sprintf('%02X%02X%02X', ord($xclrValue[0]), ord($xclrValue[1]), ord($xclrValue[2]));

            // modify the relevant style property
            if (isset($this->_mapCellXfIndex[$ixfe])) {
              $diagonal = $this->_phpExcel
                ->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])
                ->getBorders()
                ->getDiagonal();
              $diagonal
                ->getColor()
                ->setRGB($rgb);
              unset($diagonal->colorIndex);

              // normal color index does not apply, discard
            }
          }
          break;
        case 13:

          // font color
          $xclfType = self::_GetInt2d($extData, 0);

          // color type
          $xclrValue = substr($extData, 4, 4);

          // color value (value based on color type)
          if ($xclfType == 2) {
            $rgb = sprintf('%02X%02X%02X', ord($xclrValue[0]), ord($xclrValue[1]), ord($xclrValue[2]));

            // modify the relevant style property
            if (isset($this->_mapCellXfIndex[$ixfe])) {
              $font = $this->_phpExcel
                ->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])
                ->getFont();
              $font
                ->getColor()
                ->setRGB($rgb);
              unset($font->colorIndex);

              // normal color index does not apply, discard
            }
          }
          break;
      }
      $offset += $cb;
    }
  }
}