コード例 #1
0
ファイル: Font.php プロジェクト: moraesmv/testlink-code
 /**
  * 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;
 }
コード例 #2
0
ファイル: Style.php プロジェクト: TiMoChao/xingfu
 /**
  * Write Font
  *
  * @param 	PHPExcel_Shared_XMLWriter		$objWriter 		XML Writer
  * @param 	PHPExcel_Style_Font				$pFont			Font style
  * @throws 	Exception
  */
 private function _writeFont(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style_Font $pFont = null)
 {
     // font
     $objWriter->startElement('font');
     // Name
     $objWriter->startElement('name');
     $objWriter->writeAttribute('val', $pFont->getName());
     $objWriter->endElement();
     // Size
     $objWriter->startElement('sz');
     $objWriter->writeAttribute('val', $pFont->getSize());
     $objWriter->endElement();
     // Bold
     if ($pFont->getBold()) {
         $objWriter->startElement('b');
         $objWriter->writeAttribute('val', 'true');
         $objWriter->endElement();
     }
     // Italic
     if ($pFont->getItalic()) {
         $objWriter->startElement('i');
         $objWriter->writeAttribute('val', 'true');
         $objWriter->endElement();
     }
     // Superscript / subscript
     if ($pFont->getSuperScript() || $pFont->getSubScript()) {
         $objWriter->startElement('vertAlign');
         if ($pFont->getSuperScript()) {
             $objWriter->writeAttribute('val', 'superscript');
         } else {
             if ($pFont->getSubScript()) {
                 $objWriter->writeAttribute('val', 'subscript');
             }
         }
         $objWriter->endElement();
     }
     // Underline
     $objWriter->startElement('u');
     $objWriter->writeAttribute('val', $pFont->getUnderline());
     $objWriter->endElement();
     // Striketrough
     if ($pFont->getStriketrough()) {
         $objWriter->startElement('strike');
         $objWriter->writeAttribute('val', 'true');
         $objWriter->endElement();
     }
     // Foreground color
     $objWriter->startElement('color');
     $objWriter->writeAttribute('rgb', $pFont->getColor()->getARGB());
     $objWriter->endElement();
     $objWriter->endElement();
 }
コード例 #3
0
ファイル: Style.php プロジェクト: echoOly/php_base
 /**
  * Write Font
  *
  * @param 	PHPExcel_Shared_XMLWriter		$objWriter 		XML Writer
  * @param 	PHPExcel_Style_Font				$pFont			Font style
  * @throws 	Exception
  */
 private function _writeFont(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style_Font $pFont = null)
 {
     // font
     $objWriter->startElement('font');
     // Name
     $objWriter->startElement('name');
     $objWriter->writeAttribute('val', $pFont->getName());
     $objWriter->endElement();
     // Size
     $objWriter->startElement('sz');
     $objWriter->writeAttribute('val', $pFont->getSize());
     $objWriter->endElement();
     // Bold. We explicitly write this element also when false (like MS Office Excel 2007 does
     // for conditional formatting). Otherwise it will apparently not be picked up in conditional
     // formatting style dialog
     $objWriter->startElement('b');
     $objWriter->writeAttribute('val', $pFont->getBold() ? '1' : '0');
     $objWriter->endElement();
     // Italic
     $objWriter->startElement('i');
     $objWriter->writeAttribute('val', $pFont->getItalic() ? '1' : '0');
     $objWriter->endElement();
     // Superscript / subscript
     if ($pFont->getSuperScript() || $pFont->getSubScript()) {
         $objWriter->startElement('vertAlign');
         if ($pFont->getSuperScript()) {
             $objWriter->writeAttribute('val', 'superscript');
         } else {
             if ($pFont->getSubScript()) {
                 $objWriter->writeAttribute('val', 'subscript');
             }
         }
         $objWriter->endElement();
     }
     // Underline
     $objWriter->startElement('u');
     $objWriter->writeAttribute('val', $pFont->getUnderline());
     $objWriter->endElement();
     // Strikethrough
     $objWriter->startElement('strike');
     $objWriter->writeAttribute('val', $pFont->getStrikethrough() ? '1' : '0');
     $objWriter->endElement();
     // Foreground color
     $objWriter->startElement('color');
     $objWriter->writeAttribute('rgb', $pFont->getColor()->getARGB());
     $objWriter->endElement();
     $objWriter->endElement();
 }
コード例 #4
0
ファイル: Style.php プロジェクト: adit-gudhel/simpus-dev
 /**
  * Write Font
  *
  * @param 	PHPExcel_Shared_XMLWriter		$objWriter 		XML Writer
  * @param 	PHPExcel_Style_Font				$pFont			Font style
  * @throws 	PHPExcel_Writer_Exception
  */
 private function _writeFont(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style_Font $pFont = null)
 {
     // font
     $objWriter->startElement('font');
     //	Weird! The order of these elements actually makes a difference when opening Excel2007
     //		files in Excel2003 with the compatibility pack. It's not documented behaviour,
     //		and makes for a real WTF!
     // Bold. We explicitly write this element also when false (like MS Office Excel 2007 does
     // for conditional formatting). Otherwise it will apparently not be picked up in conditional
     // formatting style dialog
     if ($pFont->getBold() !== NULL) {
         $objWriter->startElement('b');
         $objWriter->writeAttribute('val', $pFont->getBold() ? '1' : '0');
         $objWriter->endElement();
     }
     // Italic
     if ($pFont->getItalic() !== NULL) {
         $objWriter->startElement('i');
         $objWriter->writeAttribute('val', $pFont->getItalic() ? '1' : '0');
         $objWriter->endElement();
     }
     // Strikethrough
     if ($pFont->getStrikethrough() !== NULL) {
         $objWriter->startElement('strike');
         $objWriter->writeAttribute('val', $pFont->getStrikethrough() ? '1' : '0');
         $objWriter->endElement();
     }
     // Underline
     if ($pFont->getUnderline() !== NULL) {
         $objWriter->startElement('u');
         $objWriter->writeAttribute('val', $pFont->getUnderline());
         $objWriter->endElement();
     }
     // Superscript / subscript
     if ($pFont->getSuperScript() === TRUE || $pFont->getSubScript() === TRUE) {
         $objWriter->startElement('vertAlign');
         if ($pFont->getSuperScript() === TRUE) {
             $objWriter->writeAttribute('val', 'superscript');
         } else {
             if ($pFont->getSubScript() === TRUE) {
                 $objWriter->writeAttribute('val', 'subscript');
             }
         }
         $objWriter->endElement();
     }
     // Size
     if ($pFont->getSize() !== NULL) {
         $objWriter->startElement('sz');
         $objWriter->writeAttribute('val', $pFont->getSize());
         $objWriter->endElement();
     }
     // Foreground color
     if ($pFont->getColor()->getARGB() !== NULL) {
         $objWriter->startElement('color');
         $objWriter->writeAttribute('rgb', $pFont->getColor()->getARGB());
         $objWriter->endElement();
     }
     // Name
     if ($pFont->getName() !== NULL) {
         $objWriter->startElement('name');
         $objWriter->writeAttribute('val', $pFont->getName());
         $objWriter->endElement();
     }
     $objWriter->endElement();
 }