Just get one row from PHPExcel
php, phpexcel
Solution
Yes!
$row = $this->objPHPExcel->getActiveSheet()->getRowIterator($rownumber)->current();
$cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(false);
foreach ($cellIterator as $cell) {
echo $cell->getValue();
}
I don't remember if you are supposed to use `next` or `current`. If you are getting the wrong row, use `current()` instead of `next()`.
Problem
I tried to find a way to just get a row using PHPExcel. After numerous searches on the internet, I only found a way to iterate over them, with an optional start row. This lead to the following solution: ``` foreach ($this->objPHPExcel->getActiveSheet()->getRowIterator($rownumber) as $row) { $cellIterator = $row->getCellIterator(); $cellIterator->setIterateOnlyExistingCells(false); foreach ($cellIterator as $cell) { echo $cell->getValue(); } break; } ``` but this feels a little ugly. Is there another way to do it?