예제 #1
0
 /**
  * Returns the content of the "<borders>" section.
  *
  * @return string
  */
 protected function getBordersSectionContent()
 {
     $registeredStyles = $this->getRegisteredStyles();
     $registeredStylesCount = count($registeredStyles);
     $content = '<borders count="' . $registeredStylesCount . '">';
     /** @var \Box\Spout\Writer\Style\Style $style */
     foreach ($registeredStyles as $style) {
         $border = $style->getBorder();
         if ($border) {
             $content .= '<border>';
             foreach ($border->getParts() as $part) {
                 /** @var $part \Box\Spout\Writer\Style\BorderPart */
                 $content .= BorderHelper::serializeBorderPart($part);
             }
             $content .= '</border>';
         } else {
             $content .= '<border><left/><right/><top/><bottom/><diagonal/></border>';
         }
     }
     $content .= '</borders>';
     return $content;
 }
예제 #2
0
 /**
  * Returns the content of the "<borders>" section.
  *
  * @return string
  */
 protected function getBordersSectionContent()
 {
     // There is one default border with index 0
     $borderCount = count($this->registeredBorders) + 1;
     $content = '<borders count="' . $borderCount . '">';
     // Default border starting at index 0
     $content .= '<border><left/><right/><top/><bottom/></border>';
     foreach ($this->registeredBorders as $styleId) {
         /** @var \Box\Spout\Writer\Style\Style $style */
         $style = $this->styleIdToStyleMappingTable[$styleId];
         $border = $style->getBorder();
         $content .= '<border>';
         // @link https://github.com/box/spout/issues/271
         $sortOrder = ['left', 'right', 'top', 'bottom'];
         foreach ($sortOrder as $partName) {
             if ($border->hasPart($partName)) {
                 /** @var $part \Box\Spout\Writer\Style\BorderPart */
                 $part = $border->getPart($partName);
                 $content .= BorderHelper::serializeBorderPart($part);
             }
         }
         $content .= '</border>';
     }
     $content .= '</borders>';
     return $content;
 }