You are here

public function PHPExcel_Worksheet::getComment in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Worksheet.php \PHPExcel_Worksheet::getComment()

Get comment for cell

Parameters

string $pCellCoordinate Cell coordinate to get comment for:

Return value

PHPExcel_Comment

Throws

PHPExcel_Exception

1 call to PHPExcel_Worksheet::getComment()
PHPExcel_Worksheet::getCommentByColumnAndRow in vendor/phpoffice/phpexcel/Classes/PHPExcel/Worksheet.php
Get comment for cell by using numeric cell coordinates

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Worksheet.php, line 2250

Class

PHPExcel_Worksheet
PHPExcel_Worksheet

Code

public function getComment($pCellCoordinate = 'A1') {

  // Uppercase coordinate
  $pCellCoordinate = strtoupper($pCellCoordinate);
  if (strpos($pCellCoordinate, ':') !== false || strpos($pCellCoordinate, ',') !== false) {
    throw new PHPExcel_Exception('Cell coordinate string can not be a range of cells.');
  }
  else {
    if (strpos($pCellCoordinate, '$') !== false) {
      throw new PHPExcel_Exception('Cell coordinate string must not be absolute.');
    }
    else {
      if ($pCellCoordinate == '') {
        throw new PHPExcel_Exception('Cell coordinate can not be zero-length string.');
      }
      else {

        // Check if we already have a comment for this cell.
        // If not, create a new comment.
        if (isset($this->_comments[$pCellCoordinate])) {
          return $this->_comments[$pCellCoordinate];
        }
        else {
          $newComment = new PHPExcel_Comment();
          $this->_comments[$pCellCoordinate] = $newComment;
          return $newComment;
        }
      }
    }
  }
}