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

Getting unsupported type exception for DateTime objects #833

Open
sikhlana opened this issue Sep 29, 2021 · 1 comment
Open

Getting unsupported type exception for DateTime objects #833

sikhlana opened this issue Sep 29, 2021 · 1 comment

Comments

@sikhlana
Copy link

sikhlana commented Sep 29, 2021

Even though the plugin can detect DateTime objects:

if (CellTypeHelper::isDateTimeOrDateInterval($value)) {
return self::TYPE_DATE;
}

public static function isDateTimeOrDateInterval($value)
{
return (
$value instanceof \DateTime ||
$value instanceof \DateInterval
);
}

The writer does not have any appropriate parser for these objects and as a result my system is throwing this error:

Box\Spout\Common\Exception\InvalidArgumentException with message 'Trying to add a value with an unsupported type: object'

With a little bit of poking around, I found that this method is not being called anywhere within the package:

public function isDate()

Which in-turn throws the InvalidArgumentException here:

throw new InvalidArgumentException('Trying to add a value with an unsupported type: ' . \gettype($cell->getValue()));

I currently did an ugly hack to bypass this issue. Am I missing something here?

@mezuky04
Copy link

I encountered the same problem.

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

2 participants