diff --git a/Classes/PHPExcel/Worksheet.php b/Classes/PHPExcel/Worksheet.php index 2f72301f..b768dac6 100644 --- a/Classes/PHPExcel/Worksheet.php +++ b/Classes/PHPExcel/Worksheet.php @@ -643,9 +643,9 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable public function setTitle($pValue = 'Worksheet') { // Is this a 'rename' or not? - if ($this->getTitle() == $pValue) { - return; - } + if ($this->getTitle() == $pValue) { + return; + } // Syntax check self::_checkSheetTitle($pValue); @@ -657,9 +657,21 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable if ($this->getParent()->getSheetByName($pValue)) { // Use name, but append with lowest possible integer + if (PHPExcel_Shared_String::CountCharacters($pValue) > 29) { + $pValue = PHPExcel_Shared_String::Substring($pValue,0,29); + } $i = 1; while ($this->getParent()->getSheetByName($pValue . ' ' . $i)) { ++$i; + if ($i == 10) { + if (PHPExcel_Shared_String::CountCharacters($pValue) > 28) { + $pValue = PHPExcel_Shared_String::Substring($pValue,0,28); + } + } elseif ($i == 100) { + if (PHPExcel_Shared_String::CountCharacters($pValue) > 27) { + $pValue = PHPExcel_Shared_String::Substring($pValue,0,27); + } + } } $altTitle = $pValue . ' ' . $i; diff --git a/changelog.txt b/changelog.txt index 05adfc17..a66e02c1 100644 --- a/changelog.txt +++ b/changelog.txt @@ -41,7 +41,8 @@ Fixed in SVN: - Bugfix: (MBaker) Workitem 14223 - Advanced Value Binder Not Working? - Bugfix: (MBaker) Workitem 14226 - unassigned object variable in PHPExcel->removeCellXfByIndex - Bugfix: (MBaker) Workitem 14236 - problem with getting cell values from another worksheet... (if cell doesn't exist) -- Bugfix: (MBaker) Workitem 14260 & 14233 - Setting cell values to one char strings & Trouble reading one character string (thanks gorfou) +- Bugfix: (MBaker) Workitems 14260 & 14233 - Setting cell values to one char strings & Trouble reading one character string (thanks gorfou) +- Bugfix: (MBaker) Workitem 14256 - Worksheet title exception when duplicate worksheet is being renamed but exceeds the 31 character limit 2010-08-26 (v1.7.4):