getCell() public method

gets the instance of cell
public getCell ( integer $rowIndex, integer $columnIndex ) : PHPRtfLite_Table_Cell
$rowIndex integer
$columnIndex integer
return PHPRtfLite_Table_Cell
Esempio n. 1
0
 /**
  * tests setBorder on cell 2x2
  * @depends testSetBorderForCellWithRow2Column1
  *
  * @param  PHPRtfLite_Table $table
  */
 public function testSetBorderForCellWithRow2Column2(PHPRtfLite_Table $table)
 {
     $border = new PHPRtfLite_Border($table->getRtf());
     $border->setBorders(new PHPRtfLite_Border_Format(1, '#888'));
     $cell2x2 = $table->getCell(2, 2);
     $cell1x2 = $table->getCell(1, 2);
     $cell2x1 = $table->getCell(2, 1);
     $cell2x2->setBorder($border);
     $this->assertEquals('#3F3', $cell1x2->getBorder()->getBorderTop()->getColor());
     $this->assertEquals('#888', $cell1x2->getBorder()->getBorderBottom()->getColor());
     $this->assertEquals('#888', $cell2x1->getBorder()->getBorderRight()->getColor());
 }
Esempio n. 2
0
 /**
  * sets default font for all cells in the row
  *
  * @param PHPRtfLite_Font $font
  */
 public function setFont(PHPRtfLite_Font $font)
 {
     $rows = $this->_table->getRows();
     foreach ($rows as $row) {
         $cell = $this->_table->getCell($row->getRowIndex(), $this->_columnIndex);
         $cell->setFont($font);
     }
 }
Esempio n. 3
0
 /**
  * sets default font for all cells in the row
  *
  * @param PHPRtfLite_Font $font
  */
 public function setFont(PHPRtfLite_Font $font)
 {
     $columns = $this->_table->getColumns();
     foreach ($columns as $i => $column) {
         $cell = $this->_table->getCell($this->_rowIndex, $column->getColumnIndex());
         $cell->setFont($font);
     }
 }
Esempio n. 4
0
 /**
  * Sets border to a cell
  *
  * @param PHPRtfLite_Border $border
  */
 public function setBorder(PHPRtfLite_Border $border)
 {
     $borderFormatTop = $border->getBorderTop();
     $borderFormatBottom = $border->getBorderBottom();
     $borderFormatLeft = $border->getBorderLeft();
     $borderFormatRight = $border->getBorderRight();
     if (!$this->_border) {
         $this->_border = new PHPRtfLite_Border();
     }
     if ($borderFormatLeft) {
         $this->_border->setBorderLeft($borderFormatLeft);
     }
     if ($borderFormatRight) {
         $this->_border->setBorderRight($borderFormatRight);
     }
     if ($borderFormatTop) {
         $this->_border->setBorderTop($borderFormatTop);
     }
     if ($borderFormatBottom) {
         $this->_border->setBorderBottom($borderFormatBottom);
     }
     if ($borderFormatTop && $this->_table->checkIfCellExists($this->_rowIndex - 1, $this->_columnIndex)) {
         $cell = $this->_table->getCell($this->_rowIndex - 1, $this->_columnIndex);
         $borderBottom = $cell->getBorder();
         if ($borderBottom == null) {
             $borderBottom = new PHPRtfLite_Border();
         }
         $borderBottom->setBorderBottom($borderFormatTop);
         $cell->setCellBorder($borderBottom);
     }
     if ($borderFormatBottom && $this->_table->checkIfCellExists($this->_rowIndex + 1, $this->_columnIndex)) {
         $cell = $this->_table->getCell($this->_rowIndex + 1, $this->_columnIndex);
         $borderTop = $cell->getBorder();
         if ($borderTop == null) {
             $borderTop = new PHPRtfLite_Border();
         }
         $borderTop->setBorderTop($borderFormatBottom);
         $cell->setCellBorder($borderTop);
     }
     if ($borderFormatLeft && $this->_table->checkIfCellExists($this->_rowIndex, $this->_columnIndex - 1)) {
         $cell = $this->_table->getCell($this->_rowIndex, $this->_columnIndex - 1);
         $borderRight = $cell->getBorder();
         if ($borderRight == null) {
             $borderRight = new PHPRtfLite_Border();
         }
         $borderRight->setBorderRight($borderFormatLeft);
         $cell->setCellBorder($borderRight);
     }
     if ($borderFormatRight && $this->_table->checkIfCellExists($this->_rowIndex, $this->_columnIndex + 1)) {
         $cell = $this->_table->getCell($this->_rowIndex, $this->_columnIndex + 1);
         $borderLeft = $cell->getBorder();
         if ($borderLeft == null) {
             $borderLeft = new PHPRtfLite_Border();
         }
         $borderLeft->setBorderLeft($borderFormatRight);
         $cell->setCellBorder($borderLeft);
     }
 }
Esempio n. 5
0
 /**
  * gets border for specific cell
  *
  * @param   integer     $rowIndex
  * @param   integer     $columnIndex
  * @return  PHPRtfLite_Border
  */
 protected function getBorderForCell($rowIndex, $columnIndex)
 {
     $cell = $this->_table->getCell($rowIndex, $columnIndex);
     $border = $cell->getBorder();
     if ($border === null) {
         $border = new PHPRtfLite_Border($this->_rtf);
         $cell->setCellBorder($border);
     }
     return $border;
 }
Esempio n. 6
0
 /**
  * tests setBackgroundForCellRange
  */
 public function testSetBackgroundForCellRange()
 {
     $backgroundColor = '#00F';
     $this->_table->addRows(3);
     $this->_table->addColumnsList(array(5, 5, 5));
     $this->_table->setBackgroundForCellRange($backgroundColor, 1, 1, 2, 2);
     for ($rowIndex = 1; $rowIndex <= 2; $rowIndex++) {
         for ($columnIndex = 1; $columnIndex <= 2; $columnIndex++) {
             $cell = $this->_table->getCell($rowIndex, $columnIndex);
             $this->assertEquals($backgroundColor, $cell->getBackgroundColor());
         }
     }
 }