Example #1
0
 private function parseFirstRowParagraphs($sdtParagraphReal, $stdCellContainer)
 {
     foreach ($sdtParagraphReal as $real) {
         $stdParagraphContainer = new HTMLElement(HTMLElement::P);
         $styleReal = $real->xpath('wpPr/wpStyle');
         if (!empty($styleReal)) {
             $styleId = (string) $styleReal[0]['wval'];
             $styles = java_values($this->sdtCell->getDocument()->getStyles()->getStyle($styleId));
             $xwpfStyle = new XWPFStyle($styles);
             $tableStyleClass = $xwpfStyle->processParagraphStyle();
             $className = $this->mainStyleSheet->getClassName($tableStyleClass);
             $stdParagraphContainer->setClass($className);
         }
         $paragraphChars = $real->xpath('wr/wt');
         if (!empty($paragraphChars)) {
             foreach ($paragraphChars as $char) {
                 $spanContainer = new HTMLElement(HTMLElement::SPAN);
                 $texto = (string) $char;
                 $text = XhtmlEntityConverter::convertToNumericalEntities(htmlentities($texto, ENT_COMPAT | ENT_XHTML));
                 $spanContainer->setInnerText($text);
                 $stdParagraphContainer->addInnerElement($spanContainer);
             }
         }
         $stdCellContainer->addInnerElement($stdParagraphContainer);
     }
     return $stdCellContainer;
 }
Example #2
0
 /**
  * @return array
  */
 public function processTableStyles()
 {
     $tableStyles = array();
     // Check if table has style ID assigned
     if ($this->getStyleID() != null) {
         // Get style name
         $style = $this->getDocumentStyles()->getStyle($this->javaTable->getStyleID());
         $xwpfStyle = new XWPFStyle($style);
         $tableStyleClass = $xwpfStyle->processStyle();
         $tableStyleClass->setAttribute("border-collapse", "collapse");
         $tableStyles['table'] = $tableStyleClass;
         $tableCellStyleClass = $xwpfStyle->processTableCellStyle();
         $tableStyles['cell'] = $tableCellStyleClass;
         $tableCellConditionalFormat = $xwpfStyle->extractConditionalFormat();
         if (!empty($tableCellConditionalFormat)) {
             $tableStyles['conditionalFormat'] = $tableCellConditionalFormat;
         }
     } else {
         $tableStyleClass = new StyleClass();
         $tableStyleClass->setAttribute("border-collapse", "collapse");
         $tableStyles['table'] = $tableStyleClass;
     }
     return $tableStyles;
 }