Example #1
0
 /**
  * Get font record data
  *
  * @return string
  */
 public function writeFont()
 {
     $font_outline = 0;
     $font_shadow = 0;
     $icv = $this->_colorIndex;
     // Index to color palette
     if ($this->_font->getSuperScript()) {
         $sss = 1;
     } else {
         if ($this->_font->getSubScript()) {
             $sss = 2;
         } else {
             $sss = 0;
         }
     }
     $bFamily = 0;
     // Font family
     $bCharSet = PHPExcel_Shared_Font::getCharsetFromFontName($this->_font->getName());
     // Character set
     $record = 0x31;
     // Record identifier
     $reserved = 0x0;
     // Reserved
     $grbit = 0x0;
     // Font attributes
     if ($this->_font->getItalic()) {
         $grbit |= 0x2;
     }
     if ($this->_font->getStrikethrough()) {
         $grbit |= 0x8;
     }
     if ($font_outline) {
         $grbit |= 0x10;
     }
     if ($font_shadow) {
         $grbit |= 0x20;
     }
     if ($this->_BIFFVersion == 0x500) {
         $data = pack("vvvvvCCCCC", $this->_font->getSize() * 20, $grbit, $icv, $this->_mapBold($this->_font->getBold()), $sss, $this->_mapUnderline($this->_font->getUnderline()), $bFamily, $bCharSet, $reserved, strlen($this->_font->getName()));
         $data .= $this->_font->getName();
     } elseif ($this->_BIFFVersion == 0x600) {
         $data = pack("vvvvvCCCC", $this->_font->getSize() * 20, $grbit, $icv, $this->_mapBold($this->_font->getBold()), $sss, $this->_mapUnderline($this->_font->getUnderline()), $bFamily, $bCharSet, $reserved);
         $data .= PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($this->_font->getName());
     }
     $length = strlen($data);
     $header = pack("vv", $record, $length);
     return $header . $data;
 }
Example #2
0
 /**
  * Write a LABELSST record or a LABEL record. Which one depends on BIFF version
  * It differs from _writeString by the writing of rich text strings.
  * @param int $row Row index (0-based)
  * @param int $col Column index (0-based)
  * @param string $str The string
  * @param mixed   $xfIndex The XF format index for the cell
  * @param array $arrcRun Index to Font record and characters beginning
  */
 private function _writeRichTextString($row, $col, $str, $xfIndex, $arrcRun)
 {
     $record = 0xfd;
     // Record identifier
     $length = 0xa;
     // Bytes to follow
     $str = PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($str, $arrcRun);
     /* check if string is already present */
     if (!isset($this->_str_table[$str])) {
         $this->_str_table[$str] = $this->_str_unique++;
     }
     $this->_str_total++;
     $header = pack('vv', $record, $length);
     $data = pack('vvvV', $row, $col, $xfIndex, $this->_str_table[$str]);
     $this->_append($header . $data);
 }
Example #3
0
 /**
  * Convert a string token to ptgStr
  *
  * @access private
  * @param string $string A string for conversion to its ptg value.
  * @return mixed the converted token on success
  */
 function _convertString($string)
 {
     // chop away beggining and ending quotes
     $string = substr($string, 1, strlen($string) - 2);
     if (strlen($string) > 255) {
         throw new Exception("String is too long");
     }
     if ($this->_BIFF_version == 0x500) {
         return pack("CC", $this->ptg['ptgStr'], strlen($string)) . $string;
     } elseif ($this->_BIFF_version == 0x600) {
         return pack('C', $this->ptg['ptgStr']) . PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($string);
     }
 }
Example #4
0
 /**
  * Writes Excel BIFF BOUNDSHEET record.
  *
  * @param PHPExcel_Worksheet  $sheet Worksheet name
  * @param integer $offset    Location of worksheet BOF
  */
 private function writeBoundSheet($sheet, $offset)
 {
     $sheetname = $sheet->getTitle();
     $record = 0x85;
     // Record identifier
     // sheet state
     switch ($sheet->getSheetState()) {
         case PHPExcel_Worksheet::SHEETSTATE_VISIBLE:
             $ss = 0x0;
             break;
         case PHPExcel_Worksheet::SHEETSTATE_HIDDEN:
             $ss = 0x1;
             break;
         case PHPExcel_Worksheet::SHEETSTATE_VERYHIDDEN:
             $ss = 0x2;
             break;
         default:
             $ss = 0x0;
             break;
     }
     // sheet type
     $st = 0x0;
     $grbit = 0x0;
     // Visibility and sheet type
     $data = pack("VCC", $offset, $ss, $st);
     $data .= PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($sheetname);
     $length = strlen($data);
     $header = pack("vv", $record, $length);
     $this->append($header . $data);
 }
Example #5
0
 /**
  * Convert a string token to ptgStr
  *
  * @access private
  * @param string $string A string for conversion to its ptg value.
  * @return mixed the converted token on success
  */
 function _convertString($string)
 {
     // chop away beggining and ending quotes
     $string = substr($string, 1, strlen($string) - 2);
     if (strlen($string) > 255) {
         throw new PHPExcel_Reader_Exception("String is too long");
     }
     return pack('C', $this->ptg['ptgStr']) . PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($string);
 }
Example #6
0
 /**
  * Writes Excel BIFF BOUNDSHEET record.
  *
  * @param string  $sheetname Worksheet name
  * @param integer $offset    Location of worksheet BOF
  * @access private
  */
 function _storeBoundsheet($sheetname, $offset)
 {
     $record = 0x85;
     // Record identifier
     $grbit = 0x0;
     // Visibility and sheet type
     if ($this->_BIFF_version == 0x600) {
         $data = pack("Vv", $offset, $grbit);
         $data .= PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($sheetname);
     } else {
         $cch = strlen($sheetname);
         // Length of sheet name
         $data = pack("VvC", $offset, $grbit, $cch);
         $data .= $sheetname;
     }
     $length = strlen($data);
     $header = pack("vv", $record, $length);
     $this->_append($header . $data);
 }
Example #7
0
 /**
  * Writes Excel BIFF BOUNDSHEET record.
  * FIXME: inconsistent with BIFF documentation
  *
  * @param string  $sheetname Worksheet name
  * @param integer $offset    Location of worksheet BOF
  * @access private
  */
 function _storeBoundsheet($sheetname, $offset)
 {
     $record = 0x85;
     // Record identifier
     if ($this->_BIFF_version == 0x600) {
         //$recordData = $this->_writeUnicodeDataShort($sheetname);
         $recordData = PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($sheetname);
         $length = 0x6 + strlen($recordData);
         // Number of bytes to follow
     } else {
         $length = 0x7 + strlen($sheetname);
         // Number of bytes to follow
     }
     $grbit = 0x0;
     // Visibility and sheet type
     $header = pack("vv", $record, $length);
     if ($this->_BIFF_version == 0x600) {
         $data = pack("Vv", $offset, $grbit);
         $this->_append($header . $data . $recordData);
     } else {
         $cch = strlen($sheetname);
         // Length of sheet name
         $data = pack("VvC", $offset, $grbit, $cch);
         $this->_append($header . $data . $sheetname);
     }
 }