diff --git a/src/Spout/Writer/ODS/Manager/WorksheetManager.php b/src/Spout/Writer/ODS/Manager/WorksheetManager.php index e5d51c10..345d1fb9 100644 --- a/src/Spout/Writer/ODS/Manager/WorksheetManager.php +++ b/src/Spout/Writer/ODS/Manager/WorksheetManager.php @@ -243,7 +243,14 @@ private function getCellXML(Cell $cell, $styleIndex, $numTimesValueRepeated) } elseif ($cell->isEmpty()) { $data .= '/>'; } else { - throw new InvalidArgumentException('Trying to add a value with an unsupported type: ' . \gettype($cell->getValue())); + $value = $cell->getValueEvenIfError(); + + $errorMessage = 'Trying to add a value with an unsupported type: ' . \gettype($value); + if (\is_object($value)) { + $errorMessage .= ' (' . \get_class($value) . ' given)'; + } + + throw new InvalidArgumentException($errorMessage); } return $data; diff --git a/src/Spout/Writer/XLSX/Manager/WorksheetManager.php b/src/Spout/Writer/XLSX/Manager/WorksheetManager.php index 60254429..18464b7e 100644 --- a/src/Spout/Writer/XLSX/Manager/WorksheetManager.php +++ b/src/Spout/Writer/XLSX/Manager/WorksheetManager.php @@ -246,7 +246,14 @@ private function getCellXML($rowIndexOneBased, $columnIndexZeroBased, Cell $cell $cellXML = ''; } } else { - throw new InvalidArgumentException('Trying to add a value with an unsupported type: ' . \gettype($cell->getValue())); + $value = $cell->getValueEvenIfError(); + + $errorMessage = 'Trying to add a value with an unsupported type: ' . \gettype($value); + if (\is_object($value)) { + $errorMessage .= ' (' . \get_class($value) . ' given)'; + } + + throw new InvalidArgumentException($errorMessage); } return $cellXML;