@@ -267,7 +267,7 @@ public function removeSheetByIndex($pIndex = 0)
267
267
268
268
if ($ pIndex > count ($ this ->_workSheetCollection ) - 1 ) {
269
269
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 }"
271
271
);
272
272
} else {
273
273
array_splice ($ this ->_workSheetCollection , $ pIndex , 1 );
@@ -294,7 +294,7 @@ public function getSheet($pIndex = 0)
294
294
295
295
if ($ pIndex > $ numSheets - 1 ) {
296
296
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 }"
298
298
);
299
299
} else {
300
300
return $ this ->_workSheetCollection [$ pIndex ];
@@ -401,8 +401,12 @@ public function getActiveSheetIndex()
401
401
*/
402
402
public function setActiveSheetIndex ($ pIndex = 0 )
403
403
{
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
+ );
406
410
} else {
407
411
$ this ->_activeSheetIndex = $ pIndex ;
408
412
}
0 commit comments