Check if the row is empty #561
Comments
👍 |
3 similar comments
👍 |
👍 |
👍 |
@dbonsch, @gmsantos, @maartenba, @MarkBaker, @Progi1984, @RomanSyroeshko : Any feedback from you guys or don't you take any issues or PR's??? |
that could be waaaay useful |
@kimegede ?? |
Is working or not? |
What about that discrepancy? However this doesn't work! |
Beware that PHP's truthy/falsy values are not always what you'd expect! String I believe something like this would work better: class PHPExcel_Worksheet_Row {
//...
public function isRowEmpty() {
$is_row_empty = true;
foreach ($this->getCellIterator() as $cell) {
if ($cell->getValue() !== null && $cell->getValue() !== '') {
$is_row_empty = false;
break;
}
}
return $is_row_empty;
}
public function getCellIterator() {
//....
}
} |
@CJDennis You might want to add trim to that empty string check so that its How would I implement this into a laravel app where i pull this package in via composer as a repository, then Well, in the end i set something into rangeToArray to extract empty rows
Note, without the array_map trim, it will not remove empty rows with weird PHPExcel columns, such as those that have "date" type, in some circumstances, because the date type somehow sets them to a space ( |
@brian-lamb-software-engineer Using Yes, dates are weird in Excel. It might be best to stick with the "post-processing" solution you've come up with. I was merely trying to show some flaws in the suggested improvements, and make them better, not fix everything. |
Thank you, that helped us. |
I didn't find built-in functionality for check if row is completely empty (all cells are without any values).
I solved it with additional helper class and following method:
Not sure if it's 100% right, but it works. I think it should be included in
PHPExcel_Worksheet_Row
something like$row->isEmpty()
.The text was updated successfully, but these errors were encountered: