PHPRtfLite_Table::mergeCellRange PHP Méthode

mergeCellRange() public méthode

merges cells of a given cell range
public mergeCellRange ( integer $startRow, integer $startColumn, integer $endRow, integer $endColumn )
$startRow integer start row
$startColumn integer start column
$endRow integer end row
$endColumn integer end column
    public function mergeCellRange($startRow, $startColumn, $endRow, $endColumn)
    {
        list($startRow, $startColumn, $endRow, $endColumn) = PHPRtfLite_Table::getValidCellRange($startRow, $startColumn, $endRow, $endColumn);
        if ($startRow == $endRow && $startColumn == $endColumn) {
            return;
        }
        if (!$this->checkIfCellExists($endRow, $endColumn)) {
            return;
        }
        for ($j = $startRow; $j <= $endRow; $j++) {
            $start = $startColumn;
            $cell = $this->getCell($j, $start);
            while ($cell->isHorizontalMerged()) {
                $start--;
                $cell = $this->getCell($j, $start);
            }
            $end = $endColumn;
            $cell = $this->getCell($j, $end);
            while ($cell->isHorizontalMerged()) {
                $end++;
                $cell = $this->getCell($j, $end + 1);
            }
            $width = 0;
            for ($i = $start; $i <= $end; $i++) {
                $cell = $this->getCell($j, $i);
                if ($j == $startRow) {
                    $cell->setVerticalMergeStart();
                } else {
                    $cell->setVerticalMerged();
                }
                $width += $cell->getWidth();
                if ($i != $start) {
                    $cell->setHorizontalMerged();
                }
            }
            $this->getCell($j, $start)->setWidth($width);
        }
    }