当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPExcel_RichText::getRichTextElements方法代码示例

本文整理汇总了PHP中PHPExcel_RichText::getRichTextElements方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_RichText::getRichTextElements方法的具体用法?PHP PHPExcel_RichText::getRichTextElements怎么用?PHP PHPExcel_RichText::getRichTextElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPExcel_RichText的用法示例。


在下文中一共展示了PHPExcel_RichText::getRichTextElements方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: writeRichText

 /**
  * Write Rich Text
  *
  * @param 	PHPExcel_Shared_XMLWriter		$objWriter 		XML Writer
  * @param 	PHPExcel_RichText				$pRichText		Rich text
  * @throws 	Exception
  */
 public function writeRichText(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_RichText $pRichText = null)
 {
     // Loop trough rich text elements
     $elements = $pRichText->getRichTextElements();
     foreach ($elements as $element) {
         // r
         $objWriter->startElement('r');
         // rPr
         if ($element instanceof PHPExcel_RichText_Run) {
             // rPr
             $objWriter->startElement('rPr');
             // rFont
             $objWriter->startElement('rFont');
             $objWriter->writeAttribute('val', $element->getFont()->getName());
             $objWriter->endElement();
             // Bold
             $objWriter->startElement('b');
             $objWriter->writeAttribute('val', $element->getFont()->getBold() ? 'true' : 'false');
             $objWriter->endElement();
             // Italic
             $objWriter->startElement('i');
             $objWriter->writeAttribute('val', $element->getFont()->getItalic() ? 'true' : 'false');
             $objWriter->endElement();
             // Striketrough
             $objWriter->startElement('strike');
             $objWriter->writeAttribute('val', $element->getFont()->getStriketrough() ? 'true' : 'false');
             $objWriter->endElement();
             // Color
             $objWriter->startElement('color');
             $objWriter->writeAttribute('rgb', $element->getFont()->getColor()->getARGB());
             $objWriter->endElement();
             // Size
             $objWriter->startElement('sz');
             $objWriter->writeAttribute('val', $element->getFont()->getSize());
             $objWriter->endElement();
             // Underline
             $objWriter->startElement('u');
             $objWriter->writeAttribute('val', $element->getFont()->getUnderline());
             $objWriter->endElement();
             $objWriter->endElement();
         }
         // t
         $objWriter->startElement('t');
         $objWriter->writeAttribute('xml:space', 'preserve');
         $objWriter->writeRaw(PHPExcel_Shared_String::ControlCharacterPHP2OOXML($element->getText()));
         $objWriter->endElement();
         $objWriter->endElement();
     }
 }
开发者ID:teungri,项目名称:RequirementsApp,代码行数:56,代码来源:StringTable.php

示例2: writeRichTextForCharts

 /**
  * Write Rich Text
  *
  * @param     PHPExcel_Shared_XMLWriter    $objWriter         XML Writer
  * @param     string|PHPExcel_RichText    $pRichText        text string or Rich text
  * @param     string                        $prefix            Optional Namespace prefix
  * @throws     PHPExcel_Writer_Exception
  */
 public function writeRichTextForCharts(PHPExcel_Shared_XMLWriter $objWriter = null, $pRichText = null, $prefix = null)
 {
     if (!$pRichText instanceof PHPExcel_RichText) {
         $textRun = $pRichText;
         $pRichText = new PHPExcel_RichText();
         $pRichText->createTextRun($textRun);
     }
     if ($prefix !== null) {
         $prefix .= ':';
     }
     // Loop through rich text elements
     $elements = $pRichText->getRichTextElements();
     foreach ($elements as $element) {
         // r
         $objWriter->startElement($prefix . 'r');
         // rPr
         $objWriter->startElement($prefix . 'rPr');
         // Bold
         $objWriter->writeAttribute('b', $element->getFont()->getBold() ? 1 : 0);
         // Italic
         $objWriter->writeAttribute('i', $element->getFont()->getItalic() ? 1 : 0);
         // Underline
         $underlineType = $element->getFont()->getUnderline();
         switch ($underlineType) {
             case 'single':
                 $underlineType = 'sng';
                 break;
             case 'double':
                 $underlineType = 'dbl';
                 break;
         }
         $objWriter->writeAttribute('u', $underlineType);
         // Strikethrough
         $objWriter->writeAttribute('strike', $element->getFont()->getStrikethrough() ? 'sngStrike' : 'noStrike');
         // rFont
         $objWriter->startElement($prefix . 'latin');
         $objWriter->writeAttribute('typeface', $element->getFont()->getName());
         $objWriter->endElement();
         // Superscript / subscript
         //                    if ($element->getFont()->getSuperScript() || $element->getFont()->getSubScript()) {
         //                        $objWriter->startElement($prefix.'vertAlign');
         //                        if ($element->getFont()->getSuperScript()) {
         //                            $objWriter->writeAttribute('val', 'superscript');
         //                        } elseif ($element->getFont()->getSubScript()) {
         //                            $objWriter->writeAttribute('val', 'subscript');
         //                        }
         //                        $objWriter->endElement();
         //                    }
         //
         $objWriter->endElement();
         // t
         $objWriter->startElement($prefix . 't');
         //                    $objWriter->writeAttribute('xml:space', 'preserve');    //    Excel2010 accepts, Excel2007 complains
         $objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML($element->getText()));
         $objWriter->endElement();
         $objWriter->endElement();
     }
 }
开发者ID:alyayazilim,项目名称:E-Ticaret-2015,代码行数:66,代码来源:StringTable.php


注:本文中的PHPExcel_RichText::getRichTextElements方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。