mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-25 01:31:26 +00:00
Bugfix: Workitem 14256 - Worksheet title exception when duplicate worksheet is being renamed but exceeds the 31 character limit
git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@61118 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user