public function PHPExcel_ReferenceHelper::updateNamedFormulas in Loft Data Grids 7.2
Same name and namespace in other branches
- 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/ReferenceHelper.php \PHPExcel_ReferenceHelper::updateNamedFormulas()
* Update named formulas (i.e. containing worksheet references / named ranges) * *
Parameters
PHPExcel $pPhpExcel Object to update: * @param string $oldName Old name (name to replace) * @param string $newName New name
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ ReferenceHelper.php, line 816
Class
- PHPExcel_ReferenceHelper
- PHPExcel_ReferenceHelper (Singleton)
Code
public function updateNamedFormulas(PHPExcel $pPhpExcel, $oldName = '', $newName = '') {
if ($oldName == '') {
return;
}
foreach ($pPhpExcel
->getWorksheetIterator() as $sheet) {
foreach ($sheet
->getCellCollection(false) as $cellID) {
$cell = $sheet
->getCell($cellID);
if ($cell !== NULL && $cell
->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) {
$formula = $cell
->getValue();
if (strpos($formula, $oldName) !== false) {
$formula = str_replace("'" . $oldName . "'!", "'" . $newName . "'!", $formula);
$formula = str_replace($oldName . "!", $newName . "!", $formula);
$cell
->setValueExplicit($formula, PHPExcel_Cell_DataType::TYPE_FORMULA);
}
}
}
}
}