Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/PHPOffice/PHPExcel into …
Browse files Browse the repository at this point in the history
…develop
  • Loading branch information
MarkBaker committed Sep 9, 2014
2 parents d4a641c + b56bcb9 commit 4baab36
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Classes/PHPExcel.php
Original file line number Diff line number Diff line change
Expand Up @@ -461,10 +461,12 @@ public function setSecurity(PHPExcel_DocumentSecurity $pValue)
* Get active sheet
*
* @return PHPExcel_Worksheet
*
* @throws PHPExcel_Exception
*/
public function getActiveSheet()
{
return $this->_workSheetCollection[$this->_activeSheetIndex];
return $this->getSheet($this->_activeSheetIndex);
}

/**
Expand Down Expand Up @@ -570,16 +572,14 @@ public function removeSheetByIndex($pIndex = 0)
*/
public function getSheet($pIndex = 0)
{

$numSheets = count($this->_workSheetCollection);

if ($pIndex > $numSheets - 1) {
if (!isset($this->_workSheetCollection[$pIndex])) {
$numSheets = $this->getSheetCount();
throw new PHPExcel_Exception(
"Your requested sheet index: {$pIndex} is out of bounds. The actual number of sheets is {$numSheets}."
);
} else {
return $this->_workSheetCollection[$pIndex];
"Your requested sheet index: {$pIndex} is out of bounds. The actual number of sheets is {$numSheets}."
);
}

return $this->_workSheetCollection[$pIndex];
}

/**
Expand Down Expand Up @@ -682,7 +682,7 @@ public function getActiveSheetIndex()
*/
public function setActiveSheetIndex($pIndex = 0)
{
$numSheets = count($this->_workSheetCollection);
$numSheets = count($this->_workSheetCollection);

if ($pIndex > $numSheets - 1) {
throw new PHPExcel_Exception(
Expand Down

0 comments on commit 4baab36

Please sign in to comment.