From aadc933827ff66178ad0737f794d37450550b605 Mon Sep 17 00:00:00 2001 From: Dominik Bonsch Date: Tue, 22 Jan 2013 20:19:06 +0100 Subject: [PATCH] Still improving the out of bounds error messages in the exceptions. --- Classes/PHPExcel.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Classes/PHPExcel.php b/Classes/PHPExcel.php index 8304b18..614fa78 100644 --- a/Classes/PHPExcel.php +++ b/Classes/PHPExcel.php @@ -267,7 +267,7 @@ class PHPExcel if ($pIndex > count($this->_workSheetCollection) - 1) { 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 { array_splice($this->_workSheetCollection, $pIndex, 1); @@ -294,7 +294,7 @@ class PHPExcel if ($pIndex > $numSheets - 1) { 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 { return $this->_workSheetCollection[$pIndex]; @@ -401,8 +401,12 @@ class PHPExcel */ public function setActiveSheetIndex($pIndex = 0) { - if ($pIndex > count($this->_workSheetCollection) - 1) { - throw new PHPExcel_Exception("Active sheet index is out of bounds."); + $numSheets = count($this->_workSheetCollection); + + 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 { $this->_activeSheetIndex = $pIndex; }