diff --git a/Classes/PHPExcel/Cell.php b/Classes/PHPExcel/Cell.php index 0462686..7f0dd1a 100644 --- a/Classes/PHPExcel/Cell.php +++ b/Classes/PHPExcel/Cell.php @@ -496,6 +496,45 @@ class PHPExcel_Cell return $this->_parent->getParent(); } + /** + * Is this cell in a merge range + * + * @return boolean + */ + public function isInMergeRange() { + return (boolean) $this->getMergeRange(); + } + + /** + * Is this cell the master (top left cell) in a merge range (that holds the actual data value) + * + * @return boolean + */ + public function isMergeRangeValueCell() { + if ($mergeRange = $this->getMergeRange()) { + $mergeRange = PHPExcel_Cell::splitRange($mergeRange); + list($startCell) = $mergeRange[0]; + if ($this->getCoordinate() === $startCell) { + return true; + } + } + return false; + } + + /** + * If this cell is in a merge range, then return the range + * + * @return string + */ + public function getMergeRange() { + foreach($this->getWorksheet()->getMergeCells() as $mergeRange) { + if ($this->isInRange($mergeRange)) { + return $mergeRange; + } + } + return false; + } + /** * Get cell style *