Skip to content

Commit aadc933

Browse files
author
Dominik Bonsch
committed
Still improving the out of bounds error messages in the exceptions.
1 parent 9926c64 commit aadc933

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Classes/PHPExcel.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public function removeSheetByIndex($pIndex = 0)
267267

268268
if ($pIndex > count($this->_workSheetCollection) - 1) {
269269
throw new PHPExcel_Exception(
270-
"The requested Sheet index: {$pIndex} is out of bounds. Actual number of sheets is {$numSheets}"
270+
"Your requested sheet index: {$pIndex} is out of bounds. The actual number of sheets is {$numSheets}"
271271
);
272272
} else {
273273
array_splice($this->_workSheetCollection, $pIndex, 1);
@@ -294,7 +294,7 @@ public function getSheet($pIndex = 0)
294294

295295
if ($pIndex > $numSheets - 1) {
296296
throw new PHPExcel_Exception(
297-
"The requested Sheet index: {$pIndex} is out of bounds. Actual number of sheets is {$numSheets}"
297+
"Your requested sheet index: {$pIndex} is out of bounds. The actual number of sheets is {$numSheets}"
298298
);
299299
} else {
300300
return $this->_workSheetCollection[$pIndex];
@@ -401,8 +401,12 @@ public function getActiveSheetIndex()
401401
*/
402402
public function setActiveSheetIndex($pIndex = 0)
403403
{
404-
if ($pIndex > count($this->_workSheetCollection) - 1) {
405-
throw new PHPExcel_Exception("Active sheet index is out of bounds.");
404+
$numSheets = count($this->_workSheetCollection);
405+
406+
if ($pIndex > $numSheets - 1) {
407+
throw new PHPExcel_Exception(
408+
"You tried to set a sheet active by an out of bounds index: {$pIndex}. The actual number of sheets is {$numSheets}."
409+
);
406410
} else {
407411
$this->_activeSheetIndex = $pIndex;
408412
}

0 commit comments

Comments
 (0)