From 756dfad85aef13f8f79e9276c835266a7dbb3f88 Mon Sep 17 00:00:00 2001 From: Dominik Bonsch Date: Tue, 22 Jan 2013 20:10:01 +0100 Subject: [PATCH] added the actual number of sheets in the out of bounds exception --- Classes/PHPExcel.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Classes/PHPExcel.php b/Classes/PHPExcel.php index 8d4101c..8f40bd6 100644 --- a/Classes/PHPExcel.php +++ b/Classes/PHPExcel.php @@ -260,8 +260,11 @@ class PHPExcel */ public function removeSheetByIndex($pIndex = 0) { + + $numSheets = count($this->_workSheetCollection); + if ($pIndex > count($this->_workSheetCollection) - 1) { - throw new PHPExcel_Exception("Sheet index is out of bounds."); + throw new PHPExcel_Exception("Sheet index is out of bounds. Actual number of sheets is {$numSheets}"); } else { array_splice($this->_workSheetCollection, $pIndex, 1); } @@ -282,8 +285,11 @@ class PHPExcel */ public function getSheet($pIndex = 0) { - if ($pIndex > count($this->_workSheetCollection) - 1) { - throw new PHPExcel_Exception("Sheet index is out of bounds."); + + $numSheets = count($this->_workSheetCollection); + + if ($pIndex > $numSheets - 1) { + throw new PHPExcel_Exception("Sheet index is out of bounds. Actual number of sheets is {$numSheets}"); } else { return $this->_workSheetCollection[$pIndex]; }