added the actual number of sheets in the out of bounds exception

This commit is contained in:
Dominik Bonsch 2013-01-22 20:10:01 +01:00
parent 9de3d5a62b
commit 756dfad85a
1 changed files with 9 additions and 3 deletions

View File

@ -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];
}