public function PHPExcel::removeCellXfByIndex in Loft Data Grids 7.2
Same name and namespace in other branches
- 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel.php \PHPExcel::removeCellXfByIndex()
Remove cellXf by index. It is ensured that all cells get their xf index updated.
Parameters
int $pIndex Index to cellXf:
Throws
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel.php, line 950
Class
- PHPExcel
- PHPExcel
Code
public function removeCellXfByIndex($pIndex = 0) {
if ($pIndex > count($this->_cellXfCollection) - 1) {
throw new PHPExcel_Exception("CellXf index is out of bounds.");
}
else {
// first remove the cellXf
array_splice($this->_cellXfCollection, $pIndex, 1);
// then update cellXf indexes for cells
foreach ($this->_workSheetCollection as $worksheet) {
foreach ($worksheet
->getCellCollection(false) as $cellID) {
$cell = $worksheet
->getCell($cellID);
$xfIndex = $cell
->getXfIndex();
if ($xfIndex > $pIndex) {
// decrease xf index by 1
$cell
->setXfIndex($xfIndex - 1);
}
else {
if ($xfIndex == $pIndex) {
// set to default xf index 0
$cell
->setXfIndex(0);
}
}
}
}
}
}