You are here

public function PHPExcel_NamedRange::setName in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/NamedRange.php \PHPExcel_NamedRange::setName()

Set name

Parameters

string $value:

Return value

PHPExcel_NamedRange

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/NamedRange.php, line 114

Class

PHPExcel_NamedRange
PHPExcel_NamedRange

Code

public function setName($value = null) {
  if ($value !== NULL) {

    // Old title
    $oldTitle = $this->_name;

    // Re-attach
    if ($this->_worksheet !== NULL) {
      $this->_worksheet
        ->getParent()
        ->removeNamedRange($this->_name, $this->_worksheet);
    }
    $this->_name = $value;
    if ($this->_worksheet !== NULL) {
      $this->_worksheet
        ->getParent()
        ->addNamedRange($this);
    }

    // New title
    $newTitle = $this->_name;
    PHPExcel_ReferenceHelper::getInstance()
      ->updateNamedFormulas($this->_worksheet
      ->getParent(), $oldTitle, $newTitle);
  }
  return $this;
}