Still improving the out of bounds error messages in the exceptions.

This commit is contained in:
Dominik Bonsch 2013-01-22 20:19:06 +01:00
parent 9926c64314
commit aadc933827

View File

@ -267,7 +267,7 @@ class PHPExcel
if ($pIndex > count($this->_workSheetCollection) - 1) { if ($pIndex > count($this->_workSheetCollection) - 1) {
throw new PHPExcel_Exception( throw new PHPExcel_Exception(
"The requested Sheet index: {$pIndex} is out of bounds. Actual number of sheets is {$numSheets}" "Your requested sheet index: {$pIndex} is out of bounds. The actual number of sheets is {$numSheets}"
); );
} else { } else {
array_splice($this->_workSheetCollection, $pIndex, 1); array_splice($this->_workSheetCollection, $pIndex, 1);
@ -294,7 +294,7 @@ class PHPExcel
if ($pIndex > $numSheets - 1) { if ($pIndex > $numSheets - 1) {
throw new PHPExcel_Exception( throw new PHPExcel_Exception(
"The requested Sheet index: {$pIndex} is out of bounds. Actual number of sheets is {$numSheets}" "Your requested sheet index: {$pIndex} is out of bounds. The actual number of sheets is {$numSheets}"
); );
} else { } else {
return $this->_workSheetCollection[$pIndex]; return $this->_workSheetCollection[$pIndex];
@ -401,8 +401,12 @@ class PHPExcel
*/ */
public function setActiveSheetIndex($pIndex = 0) public function setActiveSheetIndex($pIndex = 0)
{ {
if ($pIndex > count($this->_workSheetCollection) - 1) { $numSheets = count($this->_workSheetCollection);
throw new PHPExcel_Exception("Active sheet index is out of bounds.");
if ($pIndex > $numSheets - 1) {
throw new PHPExcel_Exception(
"You tried to set a sheet active by an out of bounds index: {$pIndex}. The actual number of sheets is {$numSheets}."
);
} else { } else {
$this->_activeSheetIndex = $pIndex; $this->_activeSheetIndex = $pIndex;
} }