public function PHPExcel::removeSheetByIndex in Loft Data Grids 7.2
Same name and namespace in other branches
- 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel.php \PHPExcel::removeSheetByIndex()
Remove sheet by index
Parameters
int $pIndex Active sheet index:
Throws
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel.php, line 546
Class
- PHPExcel
- PHPExcel
Code
public function removeSheetByIndex($pIndex = 0) {
$numSheets = count($this->_workSheetCollection);
if ($pIndex > $numSheets - 1) {
throw new PHPExcel_Exception("You tried to remove a sheet by the out of bounds index: {$pIndex}. The actual number of sheets is {$numSheets}.");
}
else {
array_splice($this->_workSheetCollection, $pIndex, 1);
}
// Adjust active sheet index if necessary
if ($this->_activeSheetIndex >= $pIndex && $pIndex > count($this->_workSheetCollection) - 1) {
--$this->_activeSheetIndex;
}
}