Esempio n. 1
0
 public function parseHeaderTableCell($stdRow)
 {
     $stdCellContainer = new HTMLElement(HTMLElement::TD);
     $tdStyle = new StyleClass();
     $wsdt = $stdRow->xpath('wsdtPr/walias');
     $wtcBorders = $stdRow->xpath('wsdtContent/wtc/wtcPr/wtcBorders');
     if ($wtcBorders) {
         $st = empty(!$wtcBorders) ? $wtcBorders[0] : null;
     }
     $borders = $this->getBorderProperties($st);
     if (!is_null($borders) and is_array($borders)) {
         if (array_key_exists('bottom', $borders)) {
             $tdStyle->setAttribute("border-bottom", "1px " . HWPFWrapper::getBorder($borders['bottom']['val']) . " #" . $borders['bottom']['color']);
         }
         if (array_key_exists('top', $borders)) {
             $tdStyle->setAttribute("border-top", "1px " . HWPFWrapper::getBorder($borders['top']['val']) . " #" . $borders['top']['color']);
         }
         if (array_key_exists('right', $borders)) {
             $tdStyle->setAttribute("border-right", "1px " . HWPFWrapper::getBorder($borders['right']['val']) . " #" . $borders['right']['color']);
         }
         if (array_key_exists('left', $borders)) {
             $tdStyle->setAttribute("border-left", "1px " . HWPFWrapper::getBorder($borders['left']['val']) . " #" . $borders['left']['color']);
         }
     }
     $backgroundColor = $stdRow->xpath('wsdtContent/wtc/wtcPr/wshd')[0]['wfill'];
     if ($backgroundColor == "FFFFFF") {
         $tdStyle->setAttribute('background-color', "#" . $borders['bottom']['color']);
     } else {
         $tdStyle->setAttribute('background-color', "#" . $backgroundColor);
     }
     $textBox = "";
     foreach ($wsdt as $walias) {
         $charText = $walias[0]['wval'];
         $textBox .= (string) $charText;
     }
     $stdCellContainer->setInnerText($textBox);
     //Add class to style sheet
     if (isset($this->mainStyleSheet)) {
         $cnm = $this->mainStyleSheet->getClassName($tdStyle);
         $stdCellContainer->setClass($cnm);
     }
     $stdCellContainer->setAttribute('colspan', '2');
     return $stdCellContainer;
 }
Esempio n. 2
0
 /**
  * @return StyleClass
  */
 public function processTableCellStyle()
 {
     $tableCellStyleClass = new StyleClass();
     $cellBorders = $this->getCellStyleBorders();
     if (!is_null($cellBorders)) {
         $tableBorders = array('right' => 'insideV', 'bottom' => 'insideH');
         foreach ($cellBorders as $key => $border) {
             if (in_array($key, $tableBorders)) {
                 $direction = $key == "insideH" ? "bottom" : "right";
                 $tableCellStyleClass->setAttribute("border-" . $direction, $border['size'] . "px " . HWPFWrapper::getBorder($border['val']) . " #" . $border['color']);
             }
         }
     }
     return $tableCellStyleClass;
 }
Esempio n. 3
0
 /**
  * @return StyleClass
  */
 public function processTableCellStyle()
 {
     $cellClass = new StyleClass();
     $cell_width = $this->getCellWidht();
     if (!empty($cell_width)) {
         $cellClass->setAttribute('width', $cell_width['value'] . 'px');
     }
     $color = $this->getColor();
     if (!is_null($color) && $color != "auto") {
         $cellClass->setAttribute("background-color", "#" . "{$color}");
     }
     $result = $this->getXMLCellObject()->xpath("wtcPr/wtcBorders");
     $tcBorders = count($result) > 0 ? $result[0] : array();
     $cellBorders = $this->getBorderProperties($tcBorders);
     //Assign border styles
     if (!is_null($cellBorders)) {
         $tableBorders = array('left', 'right', 'top', 'bottom');
         foreach ($cellBorders as $key => $border) {
             if (in_array($key, $tableBorders)) {
                 $cellClass->setAttribute("border-" . $key, $border['size'] . "px " . HWPFWrapper::getBorder($border['val']) . " #" . $border['color']);
             }
         }
     }
     return $cellClass;
 }
Esempio n. 4
0
 /**
  * @param $format
  * @return StyleClass
  * @internal param $borders
  * @internal param $conditionalTableCellStyleClass
  * @internal param $backgroundColor
  */
 private function applyConditionalFormatStyles($format)
 {
     $conditionalTableCellStyleClass = new StyleClass();
     // Get internal values
     $borders = $format["borders"];
     $backgroundColor = $format["backgroundColor"];
     // Apply first row styles
     if (!empty($borders) && is_array($borders)) {
         $conditionalCellBorders = array('bottom', 'top', 'right', 'left');
         foreach ($borders as $key => $border) {
             if (in_array($key, $conditionalCellBorders)) {
                 $conditionalTableCellStyleClass->setAttribute("border-" . $key, $border['size'] . "px " . HWPFWrapper::getBorder($border['val']) . " #" . $border['color']);
             }
         }
     }
     if (strlen($backgroundColor)) {
         $conditionalTableCellStyleClass->setAttribute("background-color", '#' . $backgroundColor);
     }
     return $conditionalTableCellStyleClass;
 }