Example #1
0
 /**
  * Cria um novo estilo para celulas baseado em um obj ZendT_Report_Cell
  * 
  * @param ZendT_Report_Cell $cell
  * @param string $styleName 
  */
 private function _createStyle(ZendT_Report_Cell $cell, $styleName)
 {
     $border = $cell->getBorders();
     $cellType = $cell->getType();
     $wrapText = '0';
     $this->_tastyles .= '<Style ss:ID="' . $styleName . '">' . "\n";
     if ($border['borders'] != '') {
         $this->_tastyles .= "<Borders>\n";
         if ($cell->getBorderTop()) {
             $thisBorder = $cell->getBorderTop();
             $this->_tastyles .= $this->_createStyleBorders('Top', $thisBorder);
         }
         if ($cell->getBorderBottom()) {
             $thisBorder = $cell->getBorderBottom();
             $this->_tastyles .= $this->_createStyleBorders('Bottom', $thisBorder);
         }
         if ($cell->getBorderRight()) {
             $thisBorder = $cell->getBorderRight();
             $this->_tastyles .= $this->_createStyleBorders('Right', $thisBorder);
         }
         if ($cell->getBorderLeft()) {
             $thisBorder = $cell->getBorderLeft();
             $this->_tastyles .= $this->_createStyleBorders('Left', $thisBorder);
         }
         $this->_tastyles .= "</Borders>\n";
     }
     if ($cell->getFontName()) {
         $fontStyle = '<Font';
         $fontStyle .= ' ss:FontName="' . $cell->getFontName() . '"';
     }
     if ($cell->getFontSize()) {
         if (!$fontStyle) {
             $fontStyle = '<Font';
         }
         $fontStyle .= ' ss:Size="' . $cell->getFontSize() . '"';
     }
     if ($cell->getFontColor()) {
         if (!$fontStyle) {
             $fontStyle = '<Font';
         }
         $fontStyle .= ' ss:Color="' . $cell->getFontColor() . '"';
     }
     if ($cell->getFontBold()) {
         if (!$fontStyle) {
             $fontStyle = '<Font';
         }
         $fontStyle .= ' ss:Bold="1"';
     }
     if ($cell->getFontItalic()) {
         if (!$fontStyle) {
             $fontStyle = '<Font';
         }
         $fontStyle .= ' ss:Italic="1"';
     }
     if ($cell->getTextDecoration()) {
         if (!$fontStyle) {
             $fontStyle = '<Font';
         }
         $fontStyle .= ' ss:Underline="Single"';
     }
     if ($fontStyle) {
         $fontStyle .= '/>' . "\n";
         $this->_tastyles .= $fontStyle;
     }
     if ($cell->getBackgroundColor()) {
         $this->_tastyles .= '<Interior ss:Color="' . $cell->getBackgroundColor() . '" ss:Pattern="Solid"/>' . "\n";
     }
     if ($cellType == 'String') {
         $wrapText = '1';
     }
     if ($cell->getTextAlign()) {
         $this->_tastyles .= '<Alignment ss:Vertical="Center" ss:Horizontal="' . $this->_alignArray[$cell->getTextAlign()] . '" ss:Indent="0" ss:WrapText="' . $wrapText . '"/>' . "\n";
     }
     if ($cellType == 'Date') {
         $this->_tastyles .= '<NumberFormat ss:Format="Short Date"/>';
     } else {
         if ($cellType == 'Time') {
             $this->_tastyles .= '<NumberFormat ss:Format="Short Time"/>';
         } else {
             if ($cellType == 'NumberTime' || $cellType == 'Numbertime') {
                 $this->_tastyles .= '<NumberFormat ss:Format="[hh]:mm:ss"/>';
             } else {
                 if ($cellType == 'DateTime' || $cellType == 'Datetime') {
                     $this->_tastyles .= '<NumberFormat ss:Format="dd/mm/yy\\ hh:mm;@"/>';
                 } else {
                     if ($cellType == 'Numeric' || $cellType == 'Integer') {
                         if ($cell->getValue() instanceof ZendT_Type_Number) {
                             $options = $cell->getValue()->getOptions();
                             if (isset($options['numDecimal'])) {
                                 if ($options['numDecimal'] > 0) {
                                     $this->_tastyles .= '<NumberFormat ss:Format="#,##0.' . str_repeat('0', $options['numDecimal']) . '"/>';
                                 } else {
                                     $this->_tastyles .= '<NumberFormat ss:Format="#,##0"/>';
                                 }
                             }
                         } else {
                             if ($cellType == 'Integer') {
                                 $this->_tastyles .= '<NumberFormat ss:Format="0"/>';
                             } else {
                                 if ($cellType == 'Numeric') {
                                     $this->_tastyles .= '<NumberFormat ss:Format="#,##0.00"/>';
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $this->_tastyles .= '</Style>' . "\n";
     return null;
 }