PHPRtfLite_Table::renderRowDefinition PHP Method

renderRowDefinition() public method

renders row definition
public renderRowDefinition ( PHPRtfLite_Table_Row $row )
$row PHPRtfLite_Table_Row
    public function renderRowDefinition(PHPRtfLite_Table_Row $row)
    {
        $rowIndex = $row->getRowIndex();
        $stream = $this->getRtf()->getWriter();
        $stream->write('\\trowd');
        if ($this->_alignment) {
            switch ($this->_alignment) {
                case self::ALIGN_CENTER:
                    $stream->write('\\trqc');
                    break;
                case self::ALIGN_RIGHT:
                    $stream->write('\\trqr');
                    break;
                default:
                    $stream->write('\\trql');
                    break;
            }
        }
        $rowHeight = $row->getHeight();
        if ($rowHeight) {
            $stream->write('\\trrh' . PHPRtfLite_Unit::getUnitInTwips($rowHeight));
        }
        if ($this->isPreventPageBreak()) {
            $stream->write('\\trkeep ');
        }
        if ($this->isFirstRowHeader() && $rowIndex == 1) {
            $stream->write('\\trhdr ');
        }
        if ($this->getLeftPosition() != '') {
            $stream->write('\\trleft' . PHPRtfLite_Unit::getUnitInTwips($this->getLeftPosition()) . ' ');
        }
        $width = 0;
        foreach ($this->getColumns() as $columnIndex => $column) {
            $cell = $this->getCell($rowIndex, $columnIndex + 1);
            // render cell definition
            if (!$cell->isHorizontalMerged()) {
                $cell->renderDefinition();
                // cell width
                $width += PHPRtfLite_Unit::getUnitInTwips($cell->getWidth());
                $stream->write('\\cellx' . $width);
            }
        }
    }

Usage Example

Exemplo n.º 1
0
 /**
  * renders rtf code for cell
  */
 public function render()
 {
     $stream = $this->_rtf->getWriter();
     $stream->write("\r\n");
     // renders container elements
     parent::render();
     $containerElements = $this->getElements();
     $numOfContainerElements = count($containerElements);
     if ($this->_table->isNestedTable()) {
         // if last container element is not a nested table, close cell
         if ($numOfContainerElements == 0 || !$containerElements[$numOfContainerElements - 1] instanceof PHPRtfLite_Table_Nested) {
             $stream->write('{\\nestcell{\\nonesttables\\par}\\pard}' . "\r\n");
             // if last cell of row, close row
             if ($this->getColumnIndex() == $this->_table->getColumnsCount()) {
                 $stream->write('{\\*\\nesttableprops ');
                 $row = $this->_table->getRow($this->_rowIndex);
                 $this->_table->renderRowDefinition($row);
                 $stream->write('\\nestrow}');
             }
         }
     } else {
         if ($numOfContainerElements > 0 && $containerElements[$numOfContainerElements - 1] instanceof PHPRtfLite_Table_Nested) {
             $stream->write('\\intbl\\itap1\\~');
         }
         // closing tag for cell definition
         $stream->write('\\cell');
     }
     $stream->write("\r\n");
 }