Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Incorrect type reported when adding an unsupported type to a cell #875

Open
cmanley opened this issue Mar 15, 2022 · 0 comments
Open

Incorrect type reported when adding an unsupported type to a cell #875

cmanley opened this issue Mar 15, 2022 · 0 comments

Comments

@cmanley
Copy link

cmanley commented Mar 15, 2022

I'm using version 3.3.0.
I experienced this exception and I've seen it reported in another ticket #713 where someone tried to pass an array as value to a cell entity:
"Trying to add a value with an unsupported type: NULL"

The wrong type is reported because

Box\Spout\Common\Entity->getValue() has this line:
return !$this->isError() ? $this->value : null;

and Box\Spout\Writer\XLSX\Manager->getCellXML() throws the exception doing this:
throw new InvalidArgumentException('Trying to add a value with an unsupported type: ' . \gettype($cell->getValue()));

so of course it'll always report NULL as type.

So perhaps the cell's getValue() should return the actual value even if it is an unsupported type, but everything reading the cell should check isError() first. That's one way. Another way would be to to create another version of getValue() by another name (e.g. getActualValue()) and use that in the exception message.

That'll save users a lot of confusion.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant