Example #1
1
 private function parseRichText($is = null)
 {
     $value = new \PHPExcel\RichText();
     if (isset($is->t)) {
         $value->createText(\PHPExcel\Shared\StringHelper::controlCharacterOOXML2PHP((string) $is->t));
     } else {
         if (is_object($is->r)) {
             foreach ($is->r as $run) {
                 if (!isset($run->rPr)) {
                     $objText = $value->createText(\PHPExcel\Shared\StringHelper::controlCharacterOOXML2PHP((string) $run->t));
                 } else {
                     $objText = $value->createTextRun(\PHPExcel\Shared\StringHelper::controlCharacterOOXML2PHP((string) $run->t));
                     if (isset($run->rPr->rFont["val"])) {
                         $objText->getFont()->setName((string) $run->rPr->rFont["val"]);
                     }
                     if (isset($run->rPr->sz["val"])) {
                         $objText->getFont()->setSize((string) $run->rPr->sz["val"]);
                     }
                     if (isset($run->rPr->color)) {
                         $objText->getFont()->setColor(new \PHPExcel\Style\Color(self::readColor($run->rPr->color)));
                     }
                     if (isset($run->rPr->b["val"]) && self::boolean((string) $run->rPr->b["val"]) || isset($run->rPr->b) && !isset($run->rPr->b["val"])) {
                         $objText->getFont()->setBold(true);
                     }
                     if (isset($run->rPr->i["val"]) && self::boolean((string) $run->rPr->i["val"]) || isset($run->rPr->i) && !isset($run->rPr->i["val"])) {
                         $objText->getFont()->setItalic(true);
                     }
                     if (isset($run->rPr->vertAlign) && isset($run->rPr->vertAlign["val"])) {
                         $vertAlign = strtolower((string) $run->rPr->vertAlign["val"]);
                         if ($vertAlign == 'superscript') {
                             $objText->getFont()->setSuperScript(true);
                         }
                         if ($vertAlign == 'subscript') {
                             $objText->getFont()->setSubScript(true);
                         }
                     }
                     if (isset($run->rPr->u) && !isset($run->rPr->u["val"])) {
                         $objText->getFont()->setUnderline(\PHPExcel\Style\Font::UNDERLINE_SINGLE);
                     } elseif (isset($run->rPr->u) && isset($run->rPr->u["val"])) {
                         $objText->getFont()->setUnderline((string) $run->rPr->u["val"]);
                     }
                     if (isset($run->rPr->strike["val"]) && self::boolean((string) $run->rPr->strike["val"]) || isset($run->rPr->strike) && !isset($run->rPr->strike["val"])) {
                         $objText->getFont()->setStrikethrough(true);
                     }
                 }
             }
         }
     }
     return $value;
 }