public setBackgroundForCellRange ( string $backgroundColor, integer $startRow, integer $startColumn, integer $endRow = null, integer $endColumn = null ) | ||
$backgroundColor | string | background color |
$startRow | integer | start row |
$startColumn | integer | start column |
$endRow | integer | end row, if null, then rotation is set only to the row range. |
$endColumn | integer | end column, if null, then rotation is set just to the column range. |
public function setBackgroundForCellRange($backgroundColor, $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->setBackgroundColor($backgroundColor);
}
}
}
/** * 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()); } } }