mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-26 15:26:03 +03:00
added the actual number of sheets in the out of bounds exception
This commit is contained in:
parent
9de3d5a62b
commit
756dfad85a
@ -260,8 +260,11 @@ class PHPExcel
|
|||||||
*/
|
*/
|
||||||
public function removeSheetByIndex($pIndex = 0)
|
public function removeSheetByIndex($pIndex = 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$numSheets = count($this->_workSheetCollection);
|
||||||
|
|
||||||
if ($pIndex > count($this->_workSheetCollection) - 1) {
|
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 {
|
} else {
|
||||||
array_splice($this->_workSheetCollection, $pIndex, 1);
|
array_splice($this->_workSheetCollection, $pIndex, 1);
|
||||||
}
|
}
|
||||||
@ -282,8 +285,11 @@ class PHPExcel
|
|||||||
*/
|
*/
|
||||||
public function getSheet($pIndex = 0)
|
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 {
|
} else {
|
||||||
return $this->_workSheetCollection[$pIndex];
|
return $this->_workSheetCollection[$pIndex];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user