/** * Esta função pega uma ZendT_Report_Cell e transforma um array pronto para ser impresso como celula * * @param ZendT_Report_Cell $cell * @return array */ public function makeCell($celula, $options = false) { if (!$celula instanceof ZendT_Report_Cell) { $celula = new ZendT_Report_Cell($celula); } $borders = $celula->getBorders(); $this->SetFont($celula->getFontName(), $celula->getStyle(), $celula->getFontSize()); $corFonteCelula = $this->hex2RGB($celula->getColor()); $this->SetTextColor($corFonteCelula['red'], $corFonteCelula['green'], $corFonteCelula['blue']); if ($borders['borders']) { if (!$borders['color']) { $borders['color'] = '#000000'; } $corBorda = $this->hex2RGB($borders['color']); $this->SetDrawColor($corBorda['red'], $corBorda['green'], $corBorda['blue']); $this->SetLineWidth($borders['width'] . 'px'); } $backgroundColor = $celula->getBackgroundColor(); if ($backgroundColor) { $colorFill = 1; $backgroundColor = $this->hex2RGB($backgroundColor); $this->SetFillColor($backgroundColor['red'], $backgroundColor['green'], $backgroundColor['blue']); } else { if (isset($options['backgroundColor'])) { $backgroundColor = $this->hex2RGB($options['backgroundColor']); $this->SetFillColor($backgroundColor['red'], $backgroundColor['green'], $backgroundColor['blue']); $colorFill = 1; } else { $colorFill = 0; } } return array('celula' => $celula, 'color' => $colorFill, 'border' => $borders['borders']); }
/** * Adiciona uma celula * * @param ZendT_Report_Cell $_cell * @return ZendT_Report_Abstract */ public function addCell(ZendT_Report_Cell $_cell) { $value = $_cell->getValue(); if ($value instanceof ZendT_Type_FileSystem) { /* $pagecount = $this->_driver->setSourceFile($value->getFile()->getFilename()); for ($page = 1; $page <= $pagecount; $page++) { $this->_driver->AddPage(); $tplidx = $this->_driver->importPage($page); $s = $this->_driver->getTemplatesize($tplidx); $this->_driver->useTemplate($tplidx, 0.5, 0.5, $s['w'], $s['h']); } */ $value = utf8_decode($value->get()); } else { if ($value instanceof ZendT_Type) { $value = utf8_decode($value->get()); } else { $value = utf8_decode($value); } } $this->_driver->SetFont($_cell->getFontName(), $_cell->getStyle(), $_cell->getFontSize()); if (strtoupper($value) == $value) { $width = $this->_driver->GetStringWidth('Z'); } else { $width = $this->_driver->GetStringWidth('z'); } if ($_cell->getWidth()) { $space = $_cell->getWidth(); } else { $space = $this->_pageWidth / $this->_maxPerLine; } $numCaracter = round($this->_pxToCm($space) / $width); $arrayValues = array(); $this->_wordWrap($value, $numCaracter, $arrayValues); if (count($arrayValues) > $this->_cells['maxLine']) { $this->_cells['maxLine'] = count($arrayValues); } $this->_cells['values'][] = $arrayValues; $this->_cells['cell'][] = $_cell; return $this; }
/** * 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; }