PHPRtfLite_Table::setFontForCellRange PHP Méthode

setFontForCellRange() public méthode

sets font to empty cells of a given cell range
public setFontForCellRange ( PHPRtfLite_Font $font, integer $startRow, integer $startColumn, integer $endRow = null, integer $endColumn = null )
$font PHPRtfLite_Font font for empty cells. The method PHPRtfLite_Table_Cell->writeToCell() overrides it with another PHPRtfLite_Font.
$startRow integer start row
$startColumn integer start column
$endRow integer end row, if null, then font is set only to the row range.
$endColumn integer end column, if null, then font is set just to the column range.
    public function setFontForCellRange(PHPRtfLite_Font $font, $startRow, $startColumn, $endRow = null, $endColumn = null)
    {
        list($startRow, $startColumn, $endRow, $endColumn) = PHPRtfLite_Table::getValidCellRange($startRow, $startColumn, $endRow, $endColumn);
        if ($this->checkIfCellExists($startRow, $startColumn) && $this->checkIfCellExists($endRow, $endColumn)) {
            $cells = $this->getCellsByCellRange($startRow, $startColumn, $endRow, $endColumn);
            foreach ($cells as $cell) {
                $cell->setFont($font);
            }
        }
    }

Usage Example

Exemple #1
0
 /**
  * tests setFontForCellRange
  */
 public function testSetFontForCell()
 {
     $font = new PHPRtfLite_Font(2, 'Arial', '#F33', '#ff0');
     $this->_table->addRows(3);
     $this->_table->addColumnsList(array(5, 5, 5));
     $this->_table->setFontForCellRange($font, 2, 2);
     $cell = $this->_table->getCell(2, 2);
     $this->assertEquals($font, $cell->getFont());
 }