Problem with Empty Cells

Topics: User Forum
Dec 16, 2013 at 8:02 AM

I am using this PHPExcel with great effect, but I seem to have a bug, where an empty cell is not always recognize as such.
For example, sometimes the empty cell is just empty: string '' (length=0)
My initialization call looks like this: $this->BezeqDataArr = $this->ExcelData->getSheet($FirstSheet)->toArray(self::EMPTY_CELL_STRING, true, true, true);

While const EMPTY_CELL_STRING = 'Empty Cell';

As you can see, debugging with var_dump, shows that the contents of the cell remains empty string, and not the string "Empty Cell".

Is it a bug? am I understanding the meaning of this feature wrong?

Dec 16, 2013 at 8:41 AM
According to documentation, toArray(): (1st) param mixed $nullValue Value returned in the array entry if a cell doesn't exist
What is not the same thing as a cell containing a string empty. If the cell exists but it contains null, $nullValue will also be used.
Dec 16, 2013 at 9:04 AM
How to tell the difference in Excel? I don't think that is possible to even see that a cell "doesnt exist" (i.e. null), from Excel itself...
which is confusing during debugging.

Wouldn't it make sense to treat an empty cell as null?
Dec 16, 2013 at 4:42 PM
If languages distinguish three cases of figures, it is not without reason (I could name a few).
In your case, since the distinction is not important, array_walk should allow you to adjust the values to your wish.